mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
parent
535037b519
commit
0473d832c1
38
.yarnclean
Normal file
38
.yarnclean
Normal file
@ -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
|
@ -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;
|
||||
}
|
||||
|
41
package.json
41
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"
|
||||
}
|
||||
}
|
||||
|
@ -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({
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 7e697531c16ee6713fa3d986447bbd4dc04a80bb
|
||||
Subproject commit 1ba775b7b8e555fdba7753ef91ac064b597dcbaf
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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}"`);
|
||||
}
|
||||
console.log(`debug: ${!!debug}`);
|
||||
console.log(`outFile: "${outFile}"`);
|
||||
console.log();
|
||||
}
|
||||
if (inputs && inputs.length) {
|
||||
log("inputs:");
|
||||
for (const input of inputs) {
|
||||
log(` "${input}"`);
|
||||
}
|
||||
}
|
||||
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.
|
||||
|
@ -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
|
||||
});
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user