ast-generator
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -43,3 +43,2 @@ #!/usr/bin/env node | ||
// src/index.ts | ||
var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk); | ||
var _commander = require('commander'); | ||
@@ -185,12 +184,12 @@ | ||
} | ||
const defined = new Set(grammar.nodes.map((n) => n.name)); | ||
const unreferenced = new Set(grammar.nodes.map((n) => n.name)); | ||
for (const name of referenced) { | ||
defined.delete(name); | ||
unreferenced.delete(name); | ||
} | ||
defined.delete("Document"); | ||
unreferenced.delete(grammar.startNode); | ||
_tinyinvariant2.default.call(void 0, | ||
defined.size === 0, | ||
`The following node kinds are never referenced: ${Array.from(defined).join( | ||
", " | ||
)}` | ||
unreferenced.size === 0, | ||
`The following node kinds are never referenced: ${Array.from( | ||
unreferenced | ||
).join(", ")}` | ||
); | ||
@@ -296,2 +295,4 @@ } | ||
return { | ||
// The first-defined node in the document is the start node | ||
startNode: Object.keys(nodesByName)[0], | ||
nodesByName, | ||
@@ -327,2 +328,13 @@ nodes: Object.keys(nodesByName).sort().map((name) => nodesByName[name]), | ||
} | ||
function asNode<N extends Node>(node: N): N { | ||
return Object.defineProperties( | ||
node, | ||
{ | ||
_kind: { enumerable: false }, | ||
range: { enumerable: false } | ||
} | ||
); | ||
} | ||
` | ||
@@ -403,3 +415,3 @@ ]; | ||
${runtimeTypeChecks.length > 0 ? `DEBUG && (() => { ${runtimeTypeChecks.join("\n")} })()` : ""} | ||
return { | ||
return asNode({ | ||
_kind: ${JSON.stringify(node.name)}, | ||
@@ -409,3 +421,3 @@ ${[...node.fields.map((field) => field.name), "range"].join( | ||
)} | ||
} | ||
}); | ||
} | ||
@@ -490,2 +502,9 @@ `); | ||
// src/index.ts | ||
function red(msg) { | ||
if (typeof process !== "undefined" && process.stdout.isTTY) { | ||
return "\x1B[31m" + msg + "\x1B[39m"; | ||
} else { | ||
return msg; | ||
} | ||
} | ||
function main() { | ||
@@ -506,4 +525,4 @@ return __async(this, null, function* () { | ||
main().then(() => process.exit(0)).catch((e) => { | ||
console.error(_chalk2.default.red(e.message)); | ||
console.error(red(e.message)); | ||
process.exit(1); | ||
}); |
{ | ||
"name": "ast-generator", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Helper to generate a TypeScript or JavaScript module for an arbitrary AST definition from a specification.", | ||
@@ -16,3 +16,4 @@ "bin": { | ||
"format": "eslint --fix src/ ; prettier --write src/", | ||
"test": "vitest run --coverage" | ||
"test": "vitest run --coverage", | ||
"release": "npm run test && npm run lint && npm run build && release-it" | ||
}, | ||
@@ -36,3 +37,2 @@ "author": "Vincent Driessen", | ||
"dependencies": { | ||
"chalk": "<5", | ||
"commander": "^10.0.0", | ||
@@ -44,12 +44,15 @@ "prettier": "^2.8.7", | ||
"devDependencies": { | ||
"@release-it/keep-a-changelog": "^5.0.0", | ||
"@types/node": "^20.11.21", | ||
"@types/prettier": "^2.7.2", | ||
"@typescript-eslint/eslint-plugin": "^5.58.0", | ||
"@vitest/coverage-istanbul": "^0.29.8", | ||
"eslint": "^8.38.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-simple-import-sort": "^10.0.0", | ||
"tsup": "^6.7.0", | ||
"vitest": "^0.29.8" | ||
"@typescript-eslint/eslint-plugin": "^7.1.0", | ||
"@vitest/coverage-istanbul": "^1.3.1", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-simple-import-sort": "^12.0.0", | ||
"release-it": "^17.1.1", | ||
"tsup": "^8.0.2", | ||
"vitest": "^1.3.1" | ||
}, | ||
"sideEffects": false | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18689
4
509
0
11
- Removedchalk@<5
- Removedansi-styles@4.3.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedsupports-color@7.2.0(transitive)