summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2019-03-08 00:53:56 +1100
committerRyan Dahl <ry@tinyclouds.org>2019-03-07 08:53:56 -0500
commit0473d832c138a7acc25372441cfa01848e6b9915 (patch)
tree94c920433911fd05772fc85cd1efb06d3da894d0
parent535037b519711d238dc0bfa2c4d2ffb4b17dec53 (diff)
Cleanup node_modules, update packages (#1894)
And fix new lint issues.
-rw-r--r--.yarnclean38
-rw-r--r--js/console.ts16
-rw-r--r--package.json41
-rw-r--r--rollup.config.js5
m---------third_party0
-rw-r--r--tools/ts_library_builder/README.md6
-rw-r--r--tools/ts_library_builder/ast_util.ts22
-rw-r--r--tools/ts_library_builder/build_library.ts74
-rw-r--r--tools/ts_library_builder/main.ts5
-rw-r--r--tools/ts_library_builder/test.ts4
10 files changed, 139 insertions, 72 deletions
diff --git a/.yarnclean b/.yarnclean
new file mode 100644
index 000000000..6d3d6bc2f
--- /dev/null
+++ b/.yarnclean
@@ -0,0 +1,38 @@
+# test directories
+__tests__
+test
+tests
+powered-test
+
+# examples
+example
+examples
+
+# code coverage directories
+coverage
+.nyc_output
+
+# build scripts
+Makefile
+Gulpfile.js
+Gruntfile.js
+
+# configs
+appveyor.yml
+circle.yml
+codeship-services.yml
+codeship-steps.yml
+wercker.yml
+.tern-project
+.gitattributes
+.editorconfig
+.*ignore
+.eslintrc
+.jshintrc
+.flowconfig
+.documentup.json
+.yarn-metadata.json
+.travis.yml
+
+# misc
+*.md
diff --git a/js/console.ts b/js/console.ts
index ac8982d4c..4cfd0211d 100644
--- a/js/console.ts
+++ b/js/console.ts
@@ -104,7 +104,7 @@ function createIterableString<T>(
}
function createArrayString(
- value: Array<unknown>,
+ value: unknown[],
ctx: ConsoleContext,
level: number,
maxLevel: number
@@ -345,7 +345,7 @@ function stringifyWithQuotes(
* @internal
*/
export function stringifyArgs(
- args: Array<unknown>,
+ args: unknown[],
options: ConsoleOptions = {}
): string {
const first = args[0];
@@ -483,7 +483,7 @@ export class Console {
}
/** Writes the arguments to stdout */
- log = (...args: Array<unknown>): void => {
+ log = (...args: unknown[]): void => {
this.printFunc(
stringifyArgs(args, {
indentLevel: this.indentLevel,
@@ -504,7 +504,7 @@ export class Console {
};
/** Writes the arguments to stdout */
- warn = (...args: Array<unknown>): void => {
+ warn = (...args: unknown[]): void => {
this.printFunc(
stringifyArgs(args, {
indentLevel: this.indentLevel,
@@ -522,7 +522,7 @@ export class Console {
*
* ref: https://console.spec.whatwg.org/#assert
*/
- assert = (condition = false, ...args: Array<unknown>): void => {
+ assert = (condition = false, ...args: unknown[]): void => {
if (condition) {
return;
}
@@ -661,7 +661,7 @@ export class Console {
timerMap.set(label, Date.now());
};
- timeLog = (label = "default", ...args: Array<unknown>): void => {
+ timeLog = (label = "default", ...args: unknown[]): void => {
label = String(label);
if (!timerMap.has(label)) {
@@ -690,14 +690,14 @@ export class Console {
this.info(`${label}: ${duration}ms`);
};
- group = (...label: Array<unknown>): void => {
+ group = (...label: unknown[]): void => {
if (label.length > 0) {
this.log(...label);
}
this.indentLevel += 2;
};
- groupCollapsed = (...label: Array<unknown>): void => {
+ groupCollapsed = (...label: unknown[]): void => {
if (this.collapsedAt == null) {
this.collapsedAt = this.indentLevel;
}
diff --git a/package.json b/package.json
index ee97f7fc7..2952b2028 100644
--- a/package.json
+++ b/package.json
@@ -1,29 +1,28 @@
{
"name": "deno",
"devDependencies": {
- "@types/base64-js": "^1.2.5",
- "@types/flatbuffers": "^1.9.0",
- "@types/prettier": "=1.15.3",
- "@types/text-encoding": "0.0.33",
- "base64-js": "^1.3.0",
- "flatbuffers": "^1.9.0",
- "magic-string": "^0.22.5",
- "prettier": "=1.15.3",
- "rollup": "0.67.0",
- "rollup-plugin-alias": "^1.4.0",
- "rollup-plugin-analyzer": "^2.1.0",
- "rollup-plugin-commonjs": "^9.1.3",
- "rollup-plugin-node-globals": "^1.2.1",
- "rollup-plugin-node-resolve": "^3.3.0",
- "rollup-plugin-replace": "^2.1.0",
- "rollup-plugin-string": "^2.0.2",
- "rollup-plugin-typescript2": "^0.16.1",
- "rollup-pluginutils": "^2.3.0",
- "ts-node": "^7.0.1",
- "ts-simple-ast": "17.1.0",
+ "@types/base64-js": "1.2.5",
+ "@types/flatbuffers": "1.9.1",
+ "@types/prettier": "1.16.1",
+ "base64-js": "1.3.0",
+ "flatbuffers": "1.9.0",
+ "magic-string": "0.25.2",
+ "prettier": "1.16.4",
+ "rollup": "1.4.1",
+ "rollup-plugin-alias": "1.5.1",
+ "rollup-plugin-analyzer": "3.0.0",
+ "rollup-plugin-commonjs": "9.1.3",
+ "rollup-plugin-node-globals": "1.4.0",
+ "rollup-plugin-node-resolve": "4.0.1",
+ "rollup-plugin-replace": "2.1.0",
+ "rollup-plugin-string": "3.0.0",
+ "rollup-plugin-typescript2": "0.19.3",
+ "rollup-pluginutils": "2.4.1",
+ "ts-morph": "1.3.0",
+ "ts-node": "8.0.2",
"tslint": "^5.10.0",
"tslint-eslint-rules": "^5.3.1",
"tslint-no-circular-imports": "^0.5.0",
- "typescript": "3.2.1"
+ "typescript": "3.2.2"
}
}
diff --git a/rollup.config.js b/rollup.config.js
index 6c1b3f03b..ad3d9059b 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -220,10 +220,7 @@ export default function makeConfig(commandOptions) {
resolveGenerated(),
// Allows rollup to resolve modules based on Node.js resolution
- nodeResolve({
- jsnext: true,
- main: true
- }),
+ nodeResolve(),
// Allows rollup to import CommonJS modules
commonjs({
diff --git a/third_party b/third_party
-Subproject 7e697531c16ee6713fa3d986447bbd4dc04a80b
+Subproject 1ba775b7b8e555fdba7753ef91ac064b597dcba
diff --git a/tools/ts_library_builder/README.md b/tools/ts_library_builder/README.md
index e2701f0fb..187d753e6 100644
--- a/tools/ts_library_builder/README.md
+++ b/tools/ts_library_builder/README.md
@@ -18,9 +18,9 @@ The tool depends upon a couple libraries:
- [`ts-node`](https://www.npmjs.com/package/ts-node) to provide just in time
transpiling of TypeScript for the tool itself.
-- [`ts-simple-ast`](https://www.npmjs.com/package/ts-simple-ast) which provides
- a more rational and functional interface to the TypeScript AST to make
- manipulations easier.
+- [`ts-morph`](https://www.npmjs.com/package/ts-morph) which provides a more
+ rational and functional interface to the TypeScript AST to make manipulations
+ easier.
- [`prettier`](https://www.npmjs.com/package/prettier) and
[`@types/prettier`](https://www.npmjs.com/package/@types/prettier) to format
the output.
diff --git a/tools/ts_library_builder/ast_util.ts b/tools/ts_library_builder/ast_util.ts
index 58aa7fb9c..f18daa398 100644
--- a/tools/ts_library_builder/ast_util.ts
+++ b/tools/ts_library_builder/ast_util.ts
@@ -15,7 +15,21 @@ import {
TypeGuards,
VariableStatement,
VariableDeclarationKind
-} from "ts-simple-ast";
+} from "ts-morph";
+
+let silent = false;
+
+/** Logs a message to the console. */
+export function log(message: any = "", ...args: any[]) {
+ if (!silent) {
+ console.log(message, ...args);
+ }
+}
+
+/** Sets the silent flag which impacts logging to the console. */
+export function setSilent(value = false): void {
+ silent = value;
+}
/** Add a property to an interface */
export function addInterfaceProperty(
@@ -169,8 +183,12 @@ export function flattenNamespace({
}
sourceFiles.add(currentSourceFile);
- const currentSourceFilePath = currentSourceFile.getFilePath();
+ const currentSourceFilePath = currentSourceFile
+ .getFilePath()
+ .replace(/(\.d)?\.ts$/, "");
+ log("Process source file:", currentSourceFilePath);
if (customSources && currentSourceFilePath in customSources) {
+ log(" Using custom source.");
output += customSources[currentSourceFilePath];
return;
}
diff --git a/tools/ts_library_builder/build_library.ts b/tools/ts_library_builder/build_library.ts
index 98a51f63f..abfb430d1 100644
--- a/tools/ts_library_builder/build_library.ts
+++ b/tools/ts_library_builder/build_library.ts
@@ -1,4 +1,5 @@
import { writeFileSync } from "fs";
+import { join } from "path";
import * as prettier from "prettier";
import {
ExpressionStatement,
@@ -8,10 +9,11 @@ import {
ts,
Type,
TypeGuards
-} from "ts-simple-ast";
+} from "ts-morph";
import {
addInterfaceProperty,
addSourceComment,
+ addTypeAlias,
addVariableDeclaration,
checkDiagnostics,
flattenNamespace,
@@ -19,10 +21,11 @@ import {
inlineFiles,
loadDtsFiles,
loadFiles,
+ log,
logDiagnostics,
namespaceSourceFile,
normalizeSlashes,
- addTypeAlias
+ setSilent
} from "./ast_util";
export interface BuildLibraryOptions {
@@ -47,6 +50,10 @@ export interface BuildLibraryOptions {
*/
inline?: string[];
+ /** An array of input files to be provided to the input project, relative to
+ * the basePath. */
+ inputs?: string[];
+
/**
* The path to the output library
*/
@@ -320,26 +327,32 @@ export function main({
basePath,
buildPath,
inline,
+ inputs,
debug,
outFile,
silent
}: BuildLibraryOptions): void {
- if (!silent) {
- console.log("-----");
- console.log("build_lib");
- console.log();
- console.log(`basePath: "${basePath}"`);
- console.log(`buildPath: "${buildPath}"`);
- if (inline && inline.length) {
- console.log(`inline:`);
- for (const filename of inline) {
- console.log(` "${filename}"`);
- }
+ setSilent(silent);
+ log("-----");
+ log("build_lib");
+ log();
+ log(`basePath: "${basePath}"`);
+ log(`buildPath: "${buildPath}"`);
+ if (inline && inline.length) {
+ log("inline:");
+ for (const filename of inline) {
+ log(` "${filename}"`);
+ }
+ }
+ if (inputs && inputs.length) {
+ log("inputs:");
+ for (const input of inputs) {
+ log(` "${input}"`);
}
- console.log(`debug: ${!!debug}`);
- console.log(`outFile: "${outFile}"`);
- console.log();
}
+ log(`debug: ${!!debug}`);
+ log(`outFile: "${outFile}"`);
+ log();
// the inputProject will take in the TypeScript files that are internal
// to Deno to be used to generate the library
@@ -348,10 +361,9 @@ export function main({
baseUrl: basePath,
declaration: true,
emitDeclarationOnly: true,
- lib: [],
- module: ModuleKind.AMD,
+ module: ModuleKind.ESNext,
moduleResolution: ModuleResolutionKind.NodeJs,
- noLib: true,
+ // noLib: true,
paths: {
"*": ["*", `${buildPath}/*`]
},
@@ -365,20 +377,23 @@ export function main({
// Add the input files we will need to generate the declarations, `globals`
// plus any modules that are importable in the runtime need to be added here
// plus the `lib.esnext` which is used as the base library
- inputProject.addExistingSourceFiles([
- `${basePath}/node_modules/typescript/lib/lib.esnext.d.ts`,
- `${basePath}/js/deno.ts`,
- `${basePath}/js/globals.ts`
- ]);
+ if (inputs) {
+ inputProject.addExistingSourceFiles(
+ inputs.map(input => join(basePath, input))
+ );
+ }
// emit the project, which will be only the declaration files
const inputEmitResult = inputProject.emitToMemory();
+ log("Emitted input project.");
+
const inputDiagnostics = inputEmitResult
.getDiagnostics()
.map(d => d.compilerObject);
logDiagnostics(inputDiagnostics);
if (inputDiagnostics.length) {
+ console.error("\nDiagnostics present during input project emit.\n");
process.exit(1);
}
@@ -419,7 +434,6 @@ export function main({
compilerOptions: {
baseUrl: buildPath,
moduleResolution: ModuleResolutionKind.NodeJs,
- noLib: true,
strict: true,
target: ScriptTarget.ESNext
},
@@ -445,7 +459,7 @@ export function main({
// Generate a object hash of substitutions of modules to use when flattening
const customSources = {
- [msgGeneratedDts.getFilePath()]: `${
+ [msgGeneratedDts.getFilePath().replace(/(\.d)?\.ts$/, "")]: `${
debug ? getSourceComment(msgGeneratedDts, basePath) : ""
}${msgGeneratedDtsText}\n`
};
@@ -462,9 +476,7 @@ export function main({
targetSourceFile: libDTs
});
- if (!silent) {
- console.log(`Merged "globals" into global scope.`);
- }
+ log(`Merged "globals" into global scope.`);
flatten({
basePath,
@@ -478,9 +490,7 @@ export function main({
targetSourceFile: libDTs
});
- if (!silent) {
- console.log(`Created module "deno" and namespace Deno.`);
- }
+ log(`Created module "deno" and namespace Deno.`);
// Inline any files that were passed in, to be used to add additional libs
// which are not part of TypeScript.
diff --git a/tools/ts_library_builder/main.ts b/tools/ts_library_builder/main.ts
index c3192a753..1d1cf14cb 100644
--- a/tools/ts_library_builder/main.ts
+++ b/tools/ts_library_builder/main.ts
@@ -42,6 +42,11 @@ buildRuntimeLib({
buildPath,
debug,
inline,
+ inputs: [
+ "node_modules/typescript/lib/lib.esnext.d.ts",
+ "js/deno.ts",
+ "js/globals.ts"
+ ],
outFile,
silent
});
diff --git a/tools/ts_library_builder/test.ts b/tools/ts_library_builder/test.ts
index 7907e1c53..b1a4ae344 100644
--- a/tools/ts_library_builder/test.ts
+++ b/tools/ts_library_builder/test.ts
@@ -4,7 +4,7 @@
// ./node_modules/.bin/ts-node --project tools/ts_library_builder/tsconfig.json tools/ts_library_builder/test.ts
import * as assert from "assert";
-import { Project, ts } from "ts-simple-ast";
+import { Project, ts } from "ts-morph";
import { flatten, mergeGlobal } from "./build_library";
import { inlineFiles, loadDtsFiles } from "./ast_util";
@@ -20,7 +20,7 @@ function setupFixtures() {
baseUrl: basePath,
declaration: true,
emitDeclarationOnly: true,
- module: ModuleKind.AMD,
+ module: ModuleKind.ESNext,
moduleResolution: ModuleResolutionKind.NodeJs,
strict: true,
stripInternal: true,