diff --git a/scripts/delete-tscparams.ts b/scripts/delete-tscparams.ts deleted file mode 100644 index 49bfef899c..0000000000 --- a/scripts/delete-tscparams.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// - -import * as fs from 'fs'; -import * as path from 'path'; - -const home = path.join(__dirname, '..'); - -function forEachTypingDir(callback: (fullPath: string, dirName: string) => void) { - fs.readdir(home, (err, dirs) => { - if (err) throw err; - for (const dir of dirs) { - const fullPath = path.join(home, dir); - fs.lstat(fullPath, (err, stats) => { - if (err) throw err; - if (stats.isDirectory()) { - callback(fullPath, dir); - } - }); - } - }); -} - -forEachTypingDir(typingPath => { - fs.readdir(typingPath, (err, files) => { - if(err) throw err; - for(const file of files) { - if (/tscparams$/.test(file)) { - const fullPath = path.join(typingPath, file); - - fs.readFile(fullPath, 'utf-8', (err, paramText) => { - if(err) throw err; - - if (paramText.length <= 2) { - fs.unlink(fullPath); - } - }); - } - } - }); -}); diff --git a/scripts/fix-reference-comments.ts b/scripts/fix-reference-comments.ts deleted file mode 100644 index ca2a18238b..0000000000 --- a/scripts/fix-reference-comments.ts +++ /dev/null @@ -1,50 +0,0 @@ -/// - -import * as fs from 'fs'; -import * as path from 'path'; - -const home = path.join(__dirname, '..'); - -function forEachTypingDir(callback: (fullPath: string, dirName: string) => void) { - fs.readdir(home, (err, dirs) => { - if (err) throw err; - for (const dir of dirs) { - const fullPath = path.join(home, dir); - fs.lstat(fullPath, (err, stats) => { - if (err) throw err; - if (stats.isDirectory()) { - callback(fullPath, dir); - } - }); - } - }); -} - -const referenceRegex = /^\/\/\/\s?\(\s*)$/gm; - -forEachTypingDir(typingPath => { - fs.readdir(typingPath, (err, files) => { - if (err) throw err; - for (const file of files) { - if (/\.ts(x?)$/.test(file)) { - const fullPath = path.join(typingPath, file); - - console.log('Read ' + fullPath); - let fileContent = fs.readFileSync(fullPath, 'utf-8'); - let match = referenceRegex.exec(fileContent); - while(match !== null) { - const referand = match[1]; - const referandFullPath = path.join(path.dirname(fullPath), referand); - if (!fs.existsSync(referandFullPath)) { - console.log(`${fullPath} references missing file ${referandFullPath}`); - fileContent = fileContent.replace(match[0], ''); - fs.writeFileSync(fullPath, fileContent, 'utf-8'); - } - - match = referenceRegex.exec(fileContent); - - } - } - } - }); -}); diff --git a/scripts/rename-entry-points.ts b/scripts/rename-entry-points.ts deleted file mode 100644 index 14fce05ce3..0000000000 --- a/scripts/rename-entry-points.ts +++ /dev/null @@ -1,70 +0,0 @@ -/// - -import * as fs from 'fs'; -import * as path from 'path'; - -function repeat(s: string, count: number) { - return Array(count + 1).join(s); -} - -function checkDir(home: string, count: number) { - fs.readdir(home, (err, dirs) => { - if (err) throw err; - - for (const dir of dirs.map(d => path.join(home, d))) { - fs.lstat(dir, (err, stats) => { - if(dir.indexOf('.git') > 0) return; - - if (err) throw err; - if (stats.isDirectory()) { - checkDir(dir, count + 1); - fs.readdir(dir, (err, files) => { - if (err) throw err; - const target = path.join(dir, 'tsconfig.json'); - fs.exists(target, exists => { - if (exists) { - const old = JSON.parse(fs.readFileSync(target, 'utf-8')); - - let entryPoint: string; - let definitionFiles = files.filter(f => (f.indexOf('.d.ts') > 0)); - if (definitionFiles.length === 1) { - entryPoint = definitionFiles[0]; - } else if(fs.existsSync(path.join(dir, 'index.d.ts'))) { - entryPoint = 'index.d.ts'; - } else { - entryPoint = path.basename(dir) + '.d.ts'; - } - - if (!fs.existsSync(path.join(dir, entryPoint))) { - console.log('No file ' + entryPoint + ' exists in ' + dir + ' so deleting it'); - fs.unlink(target); - return; - } - - let testFile: string | undefined = path.join(dir, path.basename(dir) + '-tests.ts'); - if (!fs.existsSync(testFile)) { - let onlyTest = files.filter(f => f.toLowerCase().indexOf('-tests.ts') > 0)[0]; - if (onlyTest) { - testFile = path.join(dir, onlyTest); - } else { - testFile = undefined; - } - } - if (testFile) { - old['files'] = ['index.d.ts', path.basename(testFile)]; - } else { - old['files'] = ['index.d.ts']; - } - - fs.writeFileSync(target, JSON.stringify(old, undefined, 4)); - console.log('Write to ' + target); - } - }); - }); - } - }); - } - }); -} - -checkDir(path.join(__dirname, '..'), 1); diff --git a/scripts/rename-proper-modules.ts b/scripts/rename-proper-modules.ts deleted file mode 100644 index ae5179e401..0000000000 --- a/scripts/rename-proper-modules.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -import * as fs from 'fs'; -import * as path from 'path'; - -const data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../publish-typings/data/definitions.json'), 'utf-8')); - -Object.keys(data).forEach(libName => { - const libData = data[libName]; - if(libData.kind === 'ProperModule') { - if (libData.definitionFilename !== 'index.d.ts') { - console.log(`${libName} needs renaming from ${libData.definitionFilename}`); - const src = path.join(__dirname, '..', libName, libData.definitionFilename); - const dst = path.join(__dirname, '..', libName, 'index.d.ts'); - fs.rename(src, dst); - } - } -});