Skip to content

Commit

Permalink
Cleanup node_modules, update packages (denoland#1894)
Browse files Browse the repository at this point in the history
And fix new lint issues.
  • Loading branch information
kitsonk authored and ry committed Mar 7, 2019
1 parent 535037b commit 0473d83
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 73 deletions.
38 changes: 38 additions & 0 deletions .yarnclean
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions js/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function createIterableString<T>(
}

function createArrayString(
value: Array<unknown>,
value: unknown[],
ctx: ConsoleContext,
level: number,
maxLevel: number
Expand Down Expand Up @@ -345,7 +345,7 @@ function stringifyWithQuotes(
* @internal
*/
export function stringifyArgs(
args: Array<unknown>,
args: unknown[],
options: ConsoleOptions = {}
): string {
const first = args[0];
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}
Expand Down
41 changes: 20 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
5 changes: 1 addition & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion third_party
Submodule third_party updated 2115 files
6 changes: 3 additions & 3 deletions tools/ts_library_builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 20 additions & 2 deletions tools/ts_library_builder/ast_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}
Expand Down
74 changes: 42 additions & 32 deletions tools/ts_library_builder/build_library.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { writeFileSync } from "fs";
import { join } from "path";
import * as prettier from "prettier";
import {
ExpressionStatement,
Expand All @@ -8,21 +9,23 @@ import {
ts,
Type,
TypeGuards
} from "ts-simple-ast";
} from "ts-morph";
import {
addInterfaceProperty,
addSourceComment,
addTypeAlias,
addVariableDeclaration,
checkDiagnostics,
flattenNamespace,
getSourceComment,
inlineFiles,
loadDtsFiles,
loadFiles,
log,
logDiagnostics,
namespaceSourceFile,
normalizeSlashes,
addTypeAlias
setSilent
} from "./ast_util";

export interface BuildLibraryOptions {
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
Expand All @@ -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}/*`]
},
Expand All @@ -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);
}

Expand Down Expand Up @@ -419,7 +434,6 @@ export function main({
compilerOptions: {
baseUrl: buildPath,
moduleResolution: ModuleResolutionKind.NodeJs,
noLib: true,
strict: true,
target: ScriptTarget.ESNext
},
Expand All @@ -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`
};
Expand All @@ -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,
Expand All @@ -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.
Expand Down
Loading

0 comments on commit 0473d83

Please sign in to comment.