@nasl/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -0
- package/out/apis/index.d.ts +17 -0
- package/out/apis/index.d.ts.map +1 -0
- package/out/apis/index.js +83 -0
- package/out/apis/index.js.map +1 -0
- package/out/bin/nasl-compile.d.ts +3 -0
- package/out/bin/nasl-compile.d.ts.map +1 -0
- package/out/bin/nasl-compile.js +22 -0
- package/out/bin/nasl-compile.js.map +1 -0
- package/out/bin/nasl.d.ts +3 -0
- package/out/bin/nasl.d.ts.map +1 -0
- package/out/bin/nasl.js +54 -0
- package/out/bin/nasl.js.map +1 -0
- package/out/bin/naslc.d.ts +3 -0
- package/out/bin/naslc.d.ts.map +1 -0
- package/out/bin/naslc.js +18 -0
- package/out/bin/naslc.js.map +1 -0
- package/out/commands/check.d.ts +5 -0
- package/out/commands/check.d.ts.map +1 -0
- package/out/commands/check.js +30 -0
- package/out/commands/check.js.map +1 -0
- package/out/commands/compile.d.ts +9 -0
- package/out/commands/compile.d.ts.map +1 -0
- package/out/commands/compile.js +85 -0
- package/out/commands/compile.js.map +1 -0
- package/out/commands/dev.d.ts +5 -0
- package/out/commands/dev.d.ts.map +1 -0
- package/out/commands/dev.js +16 -0
- package/out/commands/dev.js.map +1 -0
- package/out/commands/index.d.ts +5 -0
- package/out/commands/index.d.ts.map +1 -0
- package/out/commands/index.js +21 -0
- package/out/commands/index.js.map +1 -0
- package/out/commands/init.d.ts +5 -0
- package/out/commands/init.d.ts.map +1 -0
- package/out/commands/init.js +75 -0
- package/out/commands/init.js.map +1 -0
- package/out/commands/transpile.d.ts +5 -0
- package/out/commands/transpile.d.ts.map +1 -0
- package/out/commands/transpile.js +123 -0
- package/out/commands/transpile.js.map +1 -0
- package/out/index.d.ts +14 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +30 -0
- package/out/index.js.map +1 -0
- package/out/services/compose.d.ts +3 -0
- package/out/services/compose.d.ts.map +1 -0
- package/out/services/compose.js +36 -0
- package/out/services/compose.js.map +1 -0
- package/out/services/resolve.d.ts +18 -0
- package/out/services/resolve.d.ts.map +1 -0
- package/out/services/resolve.js +107 -0
- package/out/services/resolve.js.map +1 -0
- package/out/services/resolveFiles.d.ts +18 -0
- package/out/services/resolveFiles.d.ts.map +1 -0
- package/out/services/resolveFiles.js +103 -0
- package/out/services/resolveFiles.js.map +1 -0
- package/out/types/api.d.ts +107 -0
- package/out/types/api.d.ts.map +1 -0
- package/out/types/api.js +6 -0
- package/out/types/api.js.map +1 -0
- package/out/types/config.d.ts +27 -0
- package/out/types/config.d.ts.map +1 -0
- package/out/types/config.js +19 -0
- package/out/types/config.js.map +1 -0
- package/out/types/createAxios.d.ts +2 -0
- package/out/types/createAxios.d.ts.map +1 -0
- package/out/types/createAxios.js +17 -0
- package/out/types/createAxios.js.map +1 -0
- package/out/types/index.d.ts +3 -0
- package/out/types/index.d.ts.map +1 -0
- package/out/types/index.js +19 -0
- package/out/types/index.js.map +1 -0
- package/out/utils/config.d.ts +19 -0
- package/out/utils/config.d.ts.map +1 -0
- package/out/utils/config.js +114 -0
- package/out/utils/config.js.map +1 -0
- package/out/utils/exec.d.ts +11 -0
- package/out/utils/exec.d.ts.map +1 -0
- package/out/utils/exec.js +27 -0
- package/out/utils/exec.js.map +1 -0
- package/out/utils/file.d.ts +9 -0
- package/out/utils/file.d.ts.map +1 -0
- package/out/utils/file.js +67 -0
- package/out/utils/file.js.map +1 -0
- package/out/utils/index.d.ts +4 -0
- package/out/utils/index.d.ts.map +1 -0
- package/out/utils/index.js +20 -0
- package/out/utils/index.js.map +1 -0
- package/out/utils/logger.d.ts +27 -0
- package/out/utils/logger.d.ts.map +1 -0
- package/out/utils/logger.js +49 -0
- package/out/utils/logger.js.map +1 -0
- package/out/utils/string.d.ts +2 -0
- package/out/utils/string.d.ts.map +1 -0
- package/out/utils/string.js +7 -0
- package/out/utils/string.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @nasl/cli
|
|
2
|
+
|
|
3
|
+
NASL 语言的命令行工具,提供编译、检查、开发服务等功能。
|
|
4
|
+
|
|
5
|
+
目前只支持 NaturalTS 表示的 NASL 代码,编译为 Vue 和 JS。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm install -g @nasl/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 使用
|
|
14
|
+
|
|
15
|
+
### 初始化配置
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
nasl init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
会在当前目录创建 `nasl.config.json` 配置文件。
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"serverBaseURL": "https://nasl.lcap.163yun.com/api/v1/nasl", // NASL 编译服务的基础 URL
|
|
26
|
+
"representation": "NaturalTS", // NASL 语言的表示
|
|
27
|
+
"namespaceResolution": "filename-as-namespace", // 命名空间解析策略
|
|
28
|
+
"ideVersion": "4.1", // IDE 版本
|
|
29
|
+
"srcDir": "src", // 源代码目录
|
|
30
|
+
"outDir": "out" // 输出目录
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 编译 NASL 代码
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# 编译整个 src 目录
|
|
38
|
+
nasl compile
|
|
39
|
+
|
|
40
|
+
# 编译指定入口文件及其依赖
|
|
41
|
+
nasl compile src/app.frontendTypes.pc.frontends.pc.views.dashboard.views.course_selection.tsx
|
|
42
|
+
# 或使用简写
|
|
43
|
+
naslc src/app.frontendTypes.pc.frontends.pc.views.dashboard.views.course_selection.tsx
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 检查 NASL 代码
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# 检查整个 src 目录
|
|
50
|
+
nasl check
|
|
51
|
+
|
|
52
|
+
# 检查指定入口文件及其依赖
|
|
53
|
+
nasl check src/app.frontendTypes.pc.frontends.pc.views.dashboard.views.course_selection.tsx
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 启动开发服务
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
nasl dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
启动开发服务后,默认可以访问 http://localhost:3000 查看预览效果。
|
|
63
|
+
|
|
64
|
+
## 开发 CLI 工具
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# 安装依赖
|
|
68
|
+
pnpm install
|
|
69
|
+
|
|
70
|
+
# 构建
|
|
71
|
+
pnpm run build
|
|
72
|
+
|
|
73
|
+
# 开发模式(监听文件变化)
|
|
74
|
+
pnpm run dev
|
|
75
|
+
|
|
76
|
+
# 代码检查
|
|
77
|
+
pnpm run lint
|
|
78
|
+
|
|
79
|
+
# 代码修复
|
|
80
|
+
pnpm run lint:fix
|
|
81
|
+
|
|
82
|
+
# 代码格式化
|
|
83
|
+
pnpm run format
|
|
84
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ServerOptions, TranspileOptions, TranspileResult, FileInfo } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 编译 NASL 代码
|
|
4
|
+
* TODO: 实现具体的 API 调用逻辑
|
|
5
|
+
*/
|
|
6
|
+
export declare function compile(fullNaturalTS: string, options: ServerOptions): Promise<FileInfo[]>;
|
|
7
|
+
/**
|
|
8
|
+
* 检查 NASL 代码
|
|
9
|
+
* TODO: 实现具体的 API 调用逻辑
|
|
10
|
+
*/
|
|
11
|
+
export declare function check(fullNaturalTS: string, options: ServerOptions): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* 转换 NASL 代码为 AST JSON
|
|
14
|
+
* TODO: 实现具体的 API 调用逻辑
|
|
15
|
+
*/
|
|
16
|
+
export declare function transpile(files: FileInfo[], options: TranspileOptions): Promise<TranspileResult>;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/apis/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,aAAa,EAAE,gBAAgB,EAA8B,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKvI;;;GAGG;AACH,wBAAsB,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAiChG;AAED;;;GAGG;AACH,wBAAsB,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAW1F;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAmBtG"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compile = compile;
|
|
4
|
+
exports.check = check;
|
|
5
|
+
exports.transpile = transpile;
|
|
6
|
+
const createAxios_1 = require("../types/createAxios");
|
|
7
|
+
const logger_1 = require("../utils/logger");
|
|
8
|
+
const string_1 = require("../utils/string");
|
|
9
|
+
/**
|
|
10
|
+
* 编译 NASL 代码
|
|
11
|
+
* TODO: 实现具体的 API 调用逻辑
|
|
12
|
+
*/
|
|
13
|
+
async function compile(fullNaturalTS, options) {
|
|
14
|
+
// 这里需要调用实际的编译服务接口
|
|
15
|
+
// 示例实现:
|
|
16
|
+
const axios = (0, createAxios_1.createAxios)(options.serverBaseURL);
|
|
17
|
+
const res = await axios.post(`/compile/tsx?ideVersion=${options.ideVersion}&needAnnotation=true`, fullNaturalTS, {
|
|
18
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
19
|
+
});
|
|
20
|
+
const data = res.data;
|
|
21
|
+
if (data.code !== 200)
|
|
22
|
+
throw new Error(data.message);
|
|
23
|
+
const { bundle } = data.result;
|
|
24
|
+
const fileMap = bundle.frontendBundle.files;
|
|
25
|
+
const files = Object.keys(fileMap).map((key) => {
|
|
26
|
+
const fileInfo = {
|
|
27
|
+
path: key,
|
|
28
|
+
content: fileMap[key].code || '',
|
|
29
|
+
};
|
|
30
|
+
if (typeof fileInfo.content !== 'string') {
|
|
31
|
+
logger_1.Logger.error(`文件 ${key} 内容不是字符串`, fileMap[key]);
|
|
32
|
+
}
|
|
33
|
+
return fileInfo;
|
|
34
|
+
});
|
|
35
|
+
files.push({
|
|
36
|
+
path: 'backendMock.js',
|
|
37
|
+
content: `(function () {
|
|
38
|
+
${bundle.backendBundle}
|
|
39
|
+
window.backendApp = app;
|
|
40
|
+
})();
|
|
41
|
+
`,
|
|
42
|
+
});
|
|
43
|
+
return files;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 检查 NASL 代码
|
|
47
|
+
* TODO: 实现具体的 API 调用逻辑
|
|
48
|
+
*/
|
|
49
|
+
async function check(fullNaturalTS, options) {
|
|
50
|
+
const axios = (0, createAxios_1.createAxios)(options.serverBaseURL);
|
|
51
|
+
const res = await axios.post(`/check/tsx?ideVersion=${options.ideVersion}`, fullNaturalTS, {
|
|
52
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
53
|
+
});
|
|
54
|
+
const result = res.data.result;
|
|
55
|
+
const errors = (result.errors || []);
|
|
56
|
+
console.log(`共检查到 ${errors.length} 个错误`);
|
|
57
|
+
if (errors.length > 0)
|
|
58
|
+
return (0, string_1.truncate)(result.errorStr, 32000);
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 转换 NASL 代码为 AST JSON
|
|
63
|
+
* TODO: 实现具体的 API 调用逻辑
|
|
64
|
+
*/
|
|
65
|
+
async function transpile(files, options) {
|
|
66
|
+
// 这里需要调用实际的转换服务接口
|
|
67
|
+
// 示例实现:
|
|
68
|
+
throw new Error('transpile API 需要实现');
|
|
69
|
+
// 期望的实现逻辑:
|
|
70
|
+
// 1. 准备请求数据
|
|
71
|
+
// 2. 调用服务端接口
|
|
72
|
+
// 3. 返回 AST JSON 结果
|
|
73
|
+
// return {
|
|
74
|
+
// success: true,
|
|
75
|
+
// files: [
|
|
76
|
+
// {
|
|
77
|
+
// path: 'output.json',
|
|
78
|
+
// content: '{"type": "Program", ...}',
|
|
79
|
+
// },
|
|
80
|
+
// ],
|
|
81
|
+
// };
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/apis/index.ts"],"names":[],"mappings":";;AASA,0BAiCC;AAMD,sBAWC;AAMD,8BAmBC;AAnFD,sDAAmD;AACnD,4CAAyC;AACzC,4CAA2C;AAE3C;;;GAGG;AACI,KAAK,UAAU,OAAO,CAAC,aAAqB,EAAE,OAAsB;IACvE,kBAAkB;IAClB,QAAQ;IACR,MAAM,KAAK,GAAG,IAAA,yBAAW,EAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACjD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,2BAA2B,OAAO,CAAC,UAAU,sBAAsB,EAAE,aAAa,EAAE;QAC7G,OAAO,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE;KAC5C,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACtB,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAErD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;IAE/B,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;IAC5C,MAAM,KAAK,GAAG,MAAM,CAA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AC;AAED;;;GAGG;AACI,KAAK,UAAU,SAAS,CAAC,KAAiB,EAAE,OAAyB;IACxE,kBAAkB;IAClB,QAAQ;IACR,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAEtC,WAAW;IACX,YAAY;IACZ,aAAa;IACb,oBAAoB;IAEpB,WAAW;IACX,mBAAmB;IACnB,aAAa;IACb,QAAQ;IACR,6BAA6B;IAC7B,6CAA6C;IAC7C,SAAS;IACT,OAAO;IACP,KAAK;AACT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nasl-compile.d.ts","sourceRoot":"","sources":["../../src/bin/nasl-compile.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const commands_1 = require("../commands");
|
|
6
|
+
const logger_1 = require("../utils/logger");
|
|
7
|
+
const program = new commander_1.Command();
|
|
8
|
+
program
|
|
9
|
+
.name('nasl-compile')
|
|
10
|
+
.description('编译 NASL 代码为 JavaScript')
|
|
11
|
+
.argument('[entry]', '入口文件路径(可选,不填则编译整个 src 目录)')
|
|
12
|
+
.action(async (entry) => {
|
|
13
|
+
try {
|
|
14
|
+
await (0, commands_1.compileCommand)(entry);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
logger_1.Logger.error(`编译过程发生错误:${error.message}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
program.parse(process.argv);
|
|
22
|
+
//# sourceMappingURL=nasl-compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nasl-compile.js","sourceRoot":"","sources":["../../src/bin/nasl-compile.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,0CAA6C;AAC7C,4CAAyC;AAEzC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACF,IAAI,CAAC,cAAc,CAAC;KACpB,WAAW,CAAC,wBAAwB,CAAC;KACrC,QAAQ,CAAC,SAAS,EAAE,2BAA2B,CAAC;KAChD,MAAM,CAAC,KAAK,EAAE,KAAc,EAAE,EAAE;IAC7B,IAAI,CAAC;QACD,MAAM,IAAA,yBAAc,EAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,eAAM,CAAC,KAAK,CAAC,YAAa,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nasl.d.ts","sourceRoot":"","sources":["../../src/bin/nasl.ts"],"names":[],"mappings":""}
|
package/out/bin/nasl.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const commands_1 = require("../commands");
|
|
9
|
+
const logger_1 = require("../utils/logger");
|
|
10
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
11
|
+
const program = new commander_1.Command();
|
|
12
|
+
program.name('nasl').description(`NASL 语言的命令行工具,提供编译、检查、开发服务等功能。
|
|
13
|
+
目前只支持 NaturalTS 表示的 NASL 代码,编译为 Vue 和 JS。
|
|
14
|
+
`).version(package_json_1.default.version).usage('[command] [options]');
|
|
15
|
+
program
|
|
16
|
+
.command('init')
|
|
17
|
+
.description('初始化 NASL 配置文件')
|
|
18
|
+
.action(() => {
|
|
19
|
+
(0, commands_1.initCommand)();
|
|
20
|
+
});
|
|
21
|
+
program
|
|
22
|
+
.command('compile [entry]')
|
|
23
|
+
.description('编译 NASL 代码为 Vue 和 JS')
|
|
24
|
+
.action(commands_1.tryCompileCommand);
|
|
25
|
+
program
|
|
26
|
+
.command('check [entry]')
|
|
27
|
+
.description('检查 NASL 代码,包括代码中的语法和语义错误')
|
|
28
|
+
.action(async (entry) => {
|
|
29
|
+
try {
|
|
30
|
+
await (0, commands_1.checkCommand)(entry);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
logger_1.Logger.error(`检查过程发生错误:${error.message}`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
program
|
|
38
|
+
.command('dev [entry]')
|
|
39
|
+
.description('启动开发服务')
|
|
40
|
+
.action(async (entry) => {
|
|
41
|
+
try {
|
|
42
|
+
await (0, commands_1.devCommand)(entry);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
logger_1.Logger.error(`开发过程发生错误:${error.message}`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
program.parse(process.argv);
|
|
50
|
+
// 如果没有提供任何命令,显示帮助信息
|
|
51
|
+
if (!process.argv.slice(2).length) {
|
|
52
|
+
program.outputHelp();
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=nasl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nasl.js","sourceRoot":"","sources":["../../src/bin/nasl.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,0CAAuG;AACvG,4CAAyC;AACzC,sEAAqC;AAErC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC;;CAEh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,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAChC,OAAO,CAAC,UAAU,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naslc.d.ts","sourceRoot":"","sources":["../../src/bin/naslc.ts"],"names":[],"mappings":""}
|
package/out/bin/naslc.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const commands_1 = require("../commands");
|
|
9
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
10
|
+
const program = new commander_1.Command();
|
|
11
|
+
program
|
|
12
|
+
.name('naslc')
|
|
13
|
+
.description('编译 NASL 代码为 Vue 和 JS')
|
|
14
|
+
.version(package_json_1.default.version)
|
|
15
|
+
.argument('[entry]', '入口文件路径(可选,不填则编译整个 src 目录)')
|
|
16
|
+
.action(commands_1.tryCompileCommand);
|
|
17
|
+
program.parse(process.argv);
|
|
18
|
+
//# sourceMappingURL=naslc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naslc.js","sourceRoot":"","sources":["../../src/bin/naslc.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,0CAAgD;AAChD,sEAAqC;AAErC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACF,IAAI,CAAC,OAAO,CAAC;KACb,WAAW,CAAC,sBAAsB,CAAC;KACnC,OAAO,CAAC,sBAAG,CAAC,OAAO,CAAC;KACpB,QAAQ,CAAC,SAAS,EAAE,2BAA2B,CAAC;KAChD,MAAM,CAAC,4BAAiB,CAAC,CAAC;AAE/B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAsB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkCommand = checkCommand;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const apis_1 = require("../apis");
|
|
6
|
+
const compose_1 = require("../services/compose");
|
|
7
|
+
const resolve_1 = require("../services/resolve");
|
|
8
|
+
/**
|
|
9
|
+
* 检查命令 - 检查 NASL 代码的语法和语义
|
|
10
|
+
*/
|
|
11
|
+
async function checkCommand(entry) {
|
|
12
|
+
utils_1.Logger.info('开始检查 NASL 代码...');
|
|
13
|
+
// 收集需要检查的文件
|
|
14
|
+
const { inputFiles, config } = await (0, resolve_1.resolveNASLFiles)(entry);
|
|
15
|
+
// 调用检查 API
|
|
16
|
+
utils_1.Logger.newLine();
|
|
17
|
+
utils_1.Logger.info('正在调用检查服务,对语法和语义进行检查...');
|
|
18
|
+
const result = await (0, apis_1.check)((0, compose_1.composeToString)(inputFiles), {
|
|
19
|
+
serverBaseURL: config.serverBaseURL,
|
|
20
|
+
ideVersion: config.ideVersion,
|
|
21
|
+
});
|
|
22
|
+
if (result) {
|
|
23
|
+
utils_1.Logger.error('\n' + result);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// Logger.debug('检查通过!');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":";;AAQA,oCAoBC;AA5BD,oCAAkC;AAClC,kCAAgC;AAChC,iDAAsD;AACtD,iDAAuD;AAEvD;;GAEG;AACI,KAAK,UAAU,YAAY,CAAC,KAAc;IAC7C,cAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAE/B,YAAY;IACZ,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,0BAAgB,EAAC,KAAK,CAAC,CAAC;IAE7D,WAAW;IACX,cAAM,CAAC,OAAO,EAAE,CAAC;IACjB,cAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,IAAA,YAAK,EAAC,IAAA,yBAAe,EAAC,UAAU,CAAC,EAAE;QACpD,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,UAAU,EAAE,MAAM,CAAC,UAAU;KAChC,CAAC,CAAC;IAEH,IAAI,MAAM,EAAE,CAAC;QACT,cAAM,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;SAAM,CAAC;QACJ,yBAAyB;IAC7B,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 编译命令 - 将 NASL 编译为 Vue 和 JS
|
|
3
|
+
*/
|
|
4
|
+
export declare function compileCommand(entry?: string): Promise<{
|
|
5
|
+
config: import("..").NASLConfig;
|
|
6
|
+
outDir: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function tryCompileCommand(entry?: string): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAsB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM;;;GAkClD;AAED,wBAAsB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,iBAOrD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.compileCommand = compileCommand;
|
|
37
|
+
exports.tryCompileCommand = tryCompileCommand;
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const utils_1 = require("../utils");
|
|
40
|
+
const apis_1 = require("../apis");
|
|
41
|
+
const compose_1 = require("../services/compose");
|
|
42
|
+
const resolve_1 = require("../services/resolve");
|
|
43
|
+
/**
|
|
44
|
+
* 编译命令 - 将 NASL 编译为 Vue 和 JS
|
|
45
|
+
*/
|
|
46
|
+
async function compileCommand(entry) {
|
|
47
|
+
utils_1.Logger.info('开始编译 NASL 代码...');
|
|
48
|
+
// 收集需要编译的文件
|
|
49
|
+
const { inputFiles, config, projectRoot } = await (0, resolve_1.resolveNASLFiles)(entry);
|
|
50
|
+
utils_1.Logger.info(`输出目录: ${config.outDir}`);
|
|
51
|
+
const outDir = path.join(projectRoot, config.outDir);
|
|
52
|
+
// 调用编译 API
|
|
53
|
+
utils_1.Logger.newLine();
|
|
54
|
+
utils_1.Logger.info('正在调用编译服务...');
|
|
55
|
+
try {
|
|
56
|
+
const outputFiles = await (0, apis_1.compile)((0, compose_1.composeToString)(inputFiles), {
|
|
57
|
+
serverBaseURL: config.serverBaseURL,
|
|
58
|
+
ideVersion: config.ideVersion,
|
|
59
|
+
});
|
|
60
|
+
utils_1.Logger.success('编译成功!');
|
|
61
|
+
// 写入输出文件
|
|
62
|
+
for (const file of outputFiles) {
|
|
63
|
+
const outputPath = path.join(outDir, file.path);
|
|
64
|
+
(0, utils_1.writeFileWithLog)(outputPath, file.content);
|
|
65
|
+
utils_1.Logger.debug(`写入文件: ${outputPath}`);
|
|
66
|
+
}
|
|
67
|
+
utils_1.Logger.info(`输出 ${outputFiles.length} 个文件`);
|
|
68
|
+
utils_1.Logger.success(`所有文件已输出到: ${outDir}`);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
utils_1.Logger.error(`编译失败:\n${error.message}`);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
return { config, outDir };
|
|
75
|
+
}
|
|
76
|
+
async function tryCompileCommand(entry) {
|
|
77
|
+
try {
|
|
78
|
+
await compileCommand(entry);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
utils_1.Logger.error(`编译过程发生错误:${error.message}`);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,wCAkCC;AAED,8CAOC;AApDD,2CAA6B;AAC7B,oCAAoD;AACpD,kCAAkC;AAClC,iDAAsD;AACtD,iDAAuD;AAEvD;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,KAAc;IAC/C,cAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAE/B,YAAY;IACZ,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,0BAAgB,EAAC,KAAK,CAAC,CAAC;IAE1E,cAAM,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAErD,WAAW;IACX,cAAM,CAAC,OAAO,EAAE,CAAC;IACjB,cAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3B,IAAI,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,IAAA,cAAO,EAAC,IAAA,yBAAe,EAAC,UAAU,CAAC,EAAE;YAC3D,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,UAAU,EAAE,MAAM,CAAC,UAAU;SAChC,CAAC,CAAC;QACH,cAAM,CAAC,OAAO,CAAC,O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ty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.devCommand = devCommand;
|
|
4
|
+
const exec_1 = require("../utils/exec");
|
|
5
|
+
const logger_1 = require("../utils/logger");
|
|
6
|
+
const compile_1 = require("./compile");
|
|
7
|
+
/**
|
|
8
|
+
* 编译命令 - 将 NASL 编译为 Vue 和 JS
|
|
9
|
+
*/
|
|
10
|
+
async function devCommand(entry) {
|
|
11
|
+
const { outDir } = await (0, compile_1.compileCommand)(entry);
|
|
12
|
+
logger_1.Logger.newLine();
|
|
13
|
+
logger_1.Logger.info('正在启动开发服务...');
|
|
14
|
+
await (0, exec_1.justExecCommandSync)('npm run dev', outDir);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":";;AAOA,gCAKC;AAZD,wCAAoD;AACpD,4CAAyC;AACzC,uCAA2C;AAE3C;;GAEG;AACI,KAAK,UAAU,UAAU,CAAC,KAAc;IAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,wBAAc,EAAC,KAAK,CAAC,CAAC;IAC/C,eAAM,CAAC,OAAO,EAAE,CAAC;IACjB,eAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3B,MAAM,IAAA,0BAAmB,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./init"), exports);
|
|
18
|
+
__exportStar(require("./compile"), exports);
|
|
19
|
+
__exportStar(require("./dev"), exports);
|
|
20
|
+
__exportStar(require("./check"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,4CAA0B;AAC1B,wCAAsB;AACtB,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAkClC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.initCommand = initCommand;
|
|
37
|
+
const fs = __importStar(require("fs-extra"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const config_1 = require("../types/config");
|
|
40
|
+
const utils_1 = require("../utils");
|
|
41
|
+
/**
|
|
42
|
+
* 初始化命令 - 创建配置文件
|
|
43
|
+
*/
|
|
44
|
+
function initCommand() {
|
|
45
|
+
const cwd = process.cwd();
|
|
46
|
+
const configPath = path.join(cwd, config_1.CONFIG_FILE_NAME);
|
|
47
|
+
// 检查配置文件是否已存在
|
|
48
|
+
if (fs.existsSync(configPath)) {
|
|
49
|
+
utils_1.Logger.warn(`配置文件已存在: ${configPath}`);
|
|
50
|
+
utils_1.Logger.info('如需重新创建,请先删除现有配置文件');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// 创建默认配置文件
|
|
54
|
+
try {
|
|
55
|
+
fs.writeFileSync(configPath, JSON.stringify(config_1.DEFAULT_CONFIG, null, 2), 'utf-8');
|
|
56
|
+
utils_1.Logger.success(`配置文件已创建: ${configPath}`);
|
|
57
|
+
utils_1.Logger.info('\n配置内容:');
|
|
58
|
+
console.log(JSON.stringify(config_1.DEFAULT_CONFIG, null, 2));
|
|
59
|
+
// 创建源代码目录
|
|
60
|
+
const srcDirPath = path.join(cwd, config_1.DEFAULT_CONFIG.srcDir);
|
|
61
|
+
fs.ensureDirSync(srcDirPath);
|
|
62
|
+
utils_1.Logger.success(`源代码目录已创建: ${srcDirPath}`);
|
|
63
|
+
utils_1.Logger.info('\n提示:');
|
|
64
|
+
utils_1.Logger.info('- 可以编辑此文件来修改配置');
|
|
65
|
+
utils_1.Logger.info(`- srcDir: 源代码目录(默认: ${config_1.DEFAULT_CONFIG.srcDir})`);
|
|
66
|
+
utils_1.Logger.info(`- outDir: 输出目录(默认: ${config_1.DEFAULT_CONFIG.outDir})`);
|
|
67
|
+
utils_1.Logger.info(`- serverBaseURL: NASL 编译服务地址`);
|
|
68
|
+
utils_1.Logger.info(`- ideVersion: IDE 版本号`);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
utils_1.Logger.error(`创建配置文件失败: ${error.message}`);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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