ts-creator
Advanced tools
Comparing version 1.2.0-d68f208c to 1.2.0-f44096c2
169
dist/cli.js
@@ -1,1 +0,168 @@ | ||
module.exports=function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(1),n=r(2),i=r(3),a=r(4),s=r(5),u=r(6);function p(e){return function(t){const r={semi:t.semi,singleQuote:t["single-quote"],jsxSingleQuote:t["jsx-single-quote"],bracketSpacing:t["bracket-spacing"],tabWidth:t["tab-width"],useTabs:t["use-tabs"],trailingComma:t["trailing-comma"],proseWrap:t["prose-wrap"]},i=t.input,s=t.output,p=t.color,l=t.target;try{const t=u.default(e||o.readFileSync(i,"utf8"),{prettierOptions:r,target:l});if(!s)return console.log((p?a.highlight(t):t)+"\n");const c=n.resolve(s);o.writeFileSync(c,e,"utf8"),console.log(`Done at ${c}`)}catch(e){throw new Error(e)}}}t.default=async function(e){const t=await s(),r=""!==t;i.strict().command({command:`$0 ${r?"":"<input> "}[options]`,describe:"A code generator to generate TypeScript code generator from TypeScript code",handler:p(r?t:void 0),builder:e=>r?e:e.positional("input",{describe:"input file path",type:"string",normalize:!0}).epilog("\nWelcome to contribute, any bugs or features please report on:\n\n* Bug: https://github.com/HearTao/ts-creator/issues/new?template=bug.md\n* Feature: https://github.com/HearTao/ts-creator/issues/new?template=feature.md\n\nAlso see the online playground:\n\n https://ts-creator.js.org\n\nHappy hack with ts-creator")}).option("t",{alias:"target",describe:"Generate target",type:"string",choices:[u.CreatorTarget.expression,u.CreatorTarget.runnable,u.CreatorTarget.esmodule],default:u.CreatorTarget.expression}).option("o",{alias:"output",describe:"Output directory",type:"string",requiresArg:!0}).option("color",{describe:"colorful result when print on terminal",type:"boolean",default:!1}).option("semi",{group:"Prettier Options",default:!1,type:"boolean"}).option("single-quote",{group:"Prettier Options",default:!0,type:"boolean"}).option("jsx-single-quote",{group:"Prettier Options",default:!1,type:"boolean"}).option("bracket-spacing",{group:"Prettier Options",default:!0,type:"boolean"}).option("tab-width",{group:"Prettier Options",default:2,type:"number"}).option("use-tabs",{group:"Prettier Options",default:!1,type:"boolean"}).option("trailing-comma",{group:"Prettier Options",default:"none",type:"string",choices:["none","es5","all"]}).option("prose-wrap",{group:"Prettier Options",default:"preserve",type:"string",choices:["always","never","preserve"]}).version().alias("v","version").showHelpOnFail(!0,"Specify --help for available options").help("h").alias("h","help").argv}},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("yargs")},function(e,t){e.exports=require("cardinal")},function(e,t){e.exports=require("get-stdin")},function(e,t){e.exports=require("./")}]); | ||
module.exports = | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = "./src/cli.ts"); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ({ | ||
/***/ "./": | ||
/*!*********************!*\ | ||
!*** external "./" ***! | ||
\*********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
eval("module.exports = require(\"./\");\n\n//# sourceURL=webpack://tsCreatorCli/external_%22./%22?"); | ||
/***/ }), | ||
/***/ "./src/cli.ts": | ||
/*!********************!*\ | ||
!*** ./src/cli.ts ***! | ||
\********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst fs = __webpack_require__(/*! fs */ \"fs\");\nconst path = __webpack_require__(/*! path */ \"path\");\nconst yargs = __webpack_require__(/*! yargs */ \"yargs\");\nconst cardinal_1 = __webpack_require__(/*! cardinal */ \"cardinal\");\nconst getStdin = __webpack_require__(/*! get-stdin */ \"get-stdin\");\nconst _1 = __webpack_require__(/*! ./ */ \"./\");\nfunction handler(data) {\n return function handler1(argv) {\n const prettierOptions = {\n semi: argv['semi'],\n singleQuote: argv['single-quote'],\n jsxSingleQuote: argv['jsx-single-quote'],\n bracketSpacing: argv['bracket-spacing'],\n tabWidth: argv['tab-width'],\n useTabs: argv['use-tabs'],\n trailingComma: argv['trailing-comma'],\n proseWrap: argv['prose-wrap']\n };\n const input = argv['input'];\n const output = argv['output'];\n const color = argv['color'];\n const target = argv['target'];\n try {\n const result = _1.default(data ? data : fs.readFileSync(input, 'utf8'), { prettierOptions, target });\n if (!output)\n return console.log((color ? cardinal_1.highlight(result) : result) + '\\n');\n const filepath = path.resolve(output);\n fs.writeFileSync(filepath, data, 'utf8');\n console.log(`Done at ${filepath}`);\n }\n catch (e) {\n throw new Error(e);\n }\n };\n}\n/** @internal */\nasync function main(args) {\n const data = await getStdin();\n const isReadData = '' !== data;\n yargs\n .strict()\n .command({\n command: `$0 ${isReadData ? '' : '<input> '}[options]`,\n describe: 'A code generator to generate TypeScript code generator from TypeScript code',\n handler: handler(isReadData ? data : undefined),\n builder: (yargs) => {\n if (isReadData)\n return yargs;\n return yargs.positional('input', {\n describe: 'input file path',\n type: 'string',\n normalize: true\n }).epilog(`\nWelcome to contribute, any bugs or features please report on:\n\n* Bug: https://github.com/HearTao/ts-creator/issues/new?template=bug.md\n* Feature: https://github.com/HearTao/ts-creator/issues/new?template=feature.md\n\nAlso see the online playground:\n\n https://ts-creator.js.org\n\nHappy hack with ts-creator`);\n }\n })\n .option('t', {\n alias: 'target',\n describe: 'Generate target',\n type: 'string',\n choices: [\n _1.CreatorTarget.expression,\n _1.CreatorTarget.runnable,\n _1.CreatorTarget.esmodule\n ],\n default: _1.CreatorTarget.expression\n })\n .option('o', {\n alias: 'output',\n describe: 'Output directory',\n type: 'string',\n requiresArg: true\n })\n .option('color', {\n describe: 'colorful result when print on terminal',\n type: 'boolean',\n default: false\n })\n .option('semi', {\n group: 'Prettier Options',\n default: false,\n type: 'boolean'\n })\n .option('single-quote', {\n group: 'Prettier Options',\n default: true,\n type: 'boolean'\n })\n .option('jsx-single-quote', {\n group: 'Prettier Options',\n default: false,\n type: 'boolean'\n })\n .option('bracket-spacing', {\n group: 'Prettier Options',\n default: true,\n type: 'boolean'\n })\n .option('tab-width', {\n group: 'Prettier Options',\n default: 2,\n type: 'number'\n })\n .option('use-tabs', {\n group: 'Prettier Options',\n default: false,\n type: 'boolean'\n })\n .option('trailing-comma', {\n group: 'Prettier Options',\n default: 'none',\n type: 'string',\n choices: ['none', 'es5', 'all']\n })\n .option('prose-wrap', {\n group: 'Prettier Options',\n default: 'preserve',\n type: 'string',\n choices: ['always', 'never', 'preserve']\n })\n .version()\n .alias('v', 'version')\n .showHelpOnFail(true, 'Specify --help for available options')\n .help('h')\n .alias('h', 'help').argv;\n}\nexports.default = main;\n\n\n//# sourceURL=webpack://tsCreatorCli/./src/cli.ts?"); | ||
/***/ }), | ||
/***/ "cardinal": | ||
/*!***************************!*\ | ||
!*** external "cardinal" ***! | ||
\***************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
eval("module.exports = require(\"cardinal\");\n\n//# sourceURL=webpack://tsCreatorCli/external_%22cardinal%22?"); | ||
/***/ }), | ||
/***/ "fs": | ||
/*!*********************!*\ | ||
!*** external "fs" ***! | ||
\*********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
eval("module.exports = require(\"fs\");\n\n//# sourceURL=webpack://tsCreatorCli/external_%22fs%22?"); | ||
/***/ }), | ||
/***/ "get-stdin": | ||
/*!****************************!*\ | ||
!*** external "get-stdin" ***! | ||
\****************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
eval("module.exports = require(\"get-stdin\");\n\n//# sourceURL=webpack://tsCreatorCli/external_%22get-stdin%22?"); | ||
/***/ }), | ||
/***/ "path": | ||
/*!***********************!*\ | ||
!*** external "path" ***! | ||
\***********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
eval("module.exports = require(\"path\");\n\n//# sourceURL=webpack://tsCreatorCli/external_%22path%22?"); | ||
/***/ }), | ||
/***/ "yargs": | ||
/*!************************!*\ | ||
!*** external "yargs" ***! | ||
\************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
eval("module.exports = require(\"yargs\");\n\n//# sourceURL=webpack://tsCreatorCli/external_%22yargs%22?"); | ||
/***/ }) | ||
/******/ }); |
{ | ||
"name": "ts-creator", | ||
"version": "1.2.0-d68f208c", | ||
"version": "1.2.0-f44096c2", | ||
"description": "A code generator to generate TypeScript code generator from TypeScript code", | ||
"main": "dist/index.js", | ||
"types": "dist/types/src/index.d.ts", | ||
"types": "dist/types/index.d.ts", | ||
"scripts": { | ||
"build": "cross-env NODE_OPTIONS=--max_old_space_size=4096 NODE_ENV=production webpack --config webpack.config.js", | ||
"dev": "cross-env NODE_OPTIONS=--max_old_space_size=4096 webpack --config webpack.config.js -w", | ||
"test": "cross-env NODE_OPTIONS=--max_old_space_size=4096 gulp --gulpfile gulpfile.test.js", | ||
"lint": "prettier --config ./prettier.json --list-different ./types/**/* ./src/**/* ./tests/**/* ./gulpfile.test.js ./webpack.config.js ./update-next.js", | ||
"prettier": "prettier --config ./prettier.json --write ./types/**/* ./src/**/* ./tests/**/* ./gulpfile.test.js ./webpack.config.js ./update-next.js", | ||
"coverage": "cross-env NODE_OPTIONS=--max_old_space_size=4096 nyc gulp --gulpfile ./gulpfile.test.js coverage" | ||
"build": "cross-env NODE_OPTIONS=--max_old_space_size=4096 gulp", | ||
"test": "cross-env NODE_OPTIONS=--max_old_space_size=4096 gulp test", | ||
"lint": "prettier --config ./prettier.json --list-different ./types/**/* ./src/**/* ./tests/**/* ./gulpfile.js ./webpack.config.js ./update-next.js", | ||
"prettier": "prettier --config ./prettier.json --write ./types/**/* ./src/**/* ./tests/**/* ./gulpfile.js ./webpack.config.js ./update-next.js", | ||
"coverage": "cross-env NODE_OPTIONS=--max_old_space_size=4096 nyc gulp coverage" | ||
}, | ||
@@ -37,2 +36,3 @@ "author": "kingwl", | ||
"devDependencies": { | ||
"@types/diff": "^4.0.1", | ||
"@types/get-stdin": "^5.0.1", | ||
@@ -47,9 +47,9 @@ "@types/gulp": "^4.0.5", | ||
"@types/yargs": "^12.0.6", | ||
"codecov": "^3.1.0", | ||
"cross-env": "^5.2.0", | ||
"codecov": "^3.1.0", | ||
"del": "^3.0.0", | ||
"diff": "^4.0.1", | ||
"gulp": "^4.0.0", | ||
"gulp-prettier": "^2.1.0", | ||
"gulp-typescript": "^5.0.0", | ||
"gulp-uglify": "^3.0.1", | ||
"gulp-uglify-es": "^1.0.4", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
@@ -61,5 +61,3 @@ "memory-fs": "^0.4.1", | ||
"ts-loader": "^5.3.3", | ||
"uglify-es": "^3.3.9", | ||
"webpack": "^4.28.4", | ||
"webpack-cli": "^3.2.1", | ||
"webpack-merge": "^4.2.1", | ||
@@ -66,0 +64,0 @@ "webpack-stream": "^5.2.1" |
@@ -44,14 +44,27 @@ import { formatFlags } from './utils' | ||
// NodeFlags.PossiblyContainsDynamicImport, NodeFlags.PossiblyContainsImportMeta, NodeFlags.Ambient, NodeFlags.InWithStatement | ||
const internalFlags: number = 1 << 19 | 1 << 20 | 1 << 22 | 1 << 23 | ||
function filterInternalFlags (flags: NodeFlags): NodeFlags { | ||
return flags &= ~internalFlags | ||
const internalFlags: number = (1 << 19) | (1 << 20) | (1 << 22) | (1 << 23) | ||
function filterInternalFlags(flags: NodeFlags): NodeFlags { | ||
return (flags &= ~internalFlags) | ||
} | ||
/** @internal */ | ||
export function transformInternalSyntaxKind(syntaxKind: string) { | ||
switch (syntaxKind) { | ||
case 'FirstContextualKeyword': | ||
return 'AbstractKeyword' | ||
case 'LastContextualKeyword': | ||
return 'OfKeyword' | ||
default: | ||
return syntaxKind | ||
} | ||
} | ||
/** @internal */ | ||
export function createNodeFlags(flags: NodeFlags) { | ||
const formattedFlags = formatFlags(filterInternalFlags(flags), NodeFlags).map(f => | ||
createPropertyAccess( | ||
createTsAccess(createIdentifier('NodeFlags')), | ||
createIdentifier(f) | ||
) | ||
const formattedFlags = formatFlags(filterInternalFlags(flags), NodeFlags).map( | ||
f => | ||
createPropertyAccess( | ||
createTsAccess(createIdentifier('NodeFlags')), | ||
createIdentifier(f) | ||
) | ||
) | ||
@@ -58,0 +71,0 @@ return connectBinary(SyntaxKind.BarToken, formattedFlags) |
@@ -6,3 +6,4 @@ import { transformSourceFile, transformNode } from './transformer' | ||
ScriptTarget, | ||
SourceFile | ||
SourceFile, | ||
ScriptKind | ||
} from 'typescript' | ||
@@ -9,0 +10,0 @@ |
@@ -167,3 +167,4 @@ import { | ||
createLiteralCall, | ||
createTsAccess | ||
createTsAccess, | ||
transformInternalSyntaxKind | ||
} from './helper' | ||
@@ -1135,3 +1136,3 @@ | ||
createTsAccess(createIdentifier('SyntaxKind')), | ||
createIdentifier(SyntaxKind[kind]) | ||
createIdentifier(transformInternalSyntaxKind(SyntaxKind[kind])) | ||
) | ||
@@ -1138,0 +1139,0 @@ } |
@@ -13,3 +13,7 @@ { | ||
"stripInternal": true | ||
} | ||
}, | ||
"include": [ | ||
"src/", | ||
"types/" | ||
] | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
22933203
26
0
7861
2
1
23