@opcat-labs/cli-opcat 1.0.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.
Files changed (48) hide show
  1. package/assets/apply_asm.cjs +130 -0
  2. package/assets/templates/.gitkeep +0 -0
  3. package/assets/templates/counter.tar.gz +0 -0
  4. package/assets/templates/demo-contract.tar.gz +0 -0
  5. package/assets/templates/demo-lib.tar.gz +0 -0
  6. package/assets/tsconfig.json +22 -0
  7. package/bin/main.js +4 -0
  8. package/dist/app.module.d.ts +3 -0
  9. package/dist/app.module.d.ts.map +1 -0
  10. package/dist/app.module.js +26 -0
  11. package/dist/app.module.js.map +1 -0
  12. package/dist/commands/compile.command.d.ts +13 -0
  13. package/dist/commands/compile.command.d.ts.map +1 -0
  14. package/dist/commands/compile.command.js +103 -0
  15. package/dist/commands/compile.command.js.map +1 -0
  16. package/dist/commands/compile.d.ts +10 -0
  17. package/dist/commands/compile.d.ts.map +1 -0
  18. package/dist/commands/compile.js +251 -0
  19. package/dist/commands/compile.js.map +1 -0
  20. package/dist/commands/deploy.command.d.ts +11 -0
  21. package/dist/commands/deploy.command.d.ts.map +1 -0
  22. package/dist/commands/deploy.command.js +79 -0
  23. package/dist/commands/deploy.command.js.map +1 -0
  24. package/dist/commands/project.command.d.ts +11 -0
  25. package/dist/commands/project.command.d.ts.map +1 -0
  26. package/dist/commands/project.command.js +94 -0
  27. package/dist/commands/project.command.js.map +1 -0
  28. package/dist/commands/project.d.ts +24 -0
  29. package/dist/commands/project.d.ts.map +1 -0
  30. package/dist/commands/project.js +217 -0
  31. package/dist/commands/project.js.map +1 -0
  32. package/dist/commands/system.command.d.ts +6 -0
  33. package/dist/commands/system.command.d.ts.map +1 -0
  34. package/dist/commands/system.command.js +41 -0
  35. package/dist/commands/system.command.js.map +1 -0
  36. package/dist/commands/version.command.d.ts +6 -0
  37. package/dist/commands/version.command.d.ts.map +1 -0
  38. package/dist/commands/version.command.js +32 -0
  39. package/dist/commands/version.command.js.map +1 -0
  40. package/dist/common/utils.d.ts +68 -0
  41. package/dist/common/utils.d.ts.map +1 -0
  42. package/dist/common/utils.js +263 -0
  43. package/dist/common/utils.js.map +1 -0
  44. package/dist/main.d.ts +2 -0
  45. package/dist/main.d.ts.map +1 -0
  46. package/dist/main.js +18 -0
  47. package/dist/main.js.map +1 -0
  48. package/package.json +50 -0
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DeployCommand = void 0;
13
+ const nest_commander_1 = require("nest-commander");
14
+ const utils_1 = require("../common/utils");
15
+ const chalk_1 = require("chalk");
16
+ const process_1 = require("process");
17
+ const fs_1 = require("fs");
18
+ const path_1 = require("path");
19
+ let DeployCommand = class DeployCommand extends nest_commander_1.CommandRunner {
20
+ constructor() {
21
+ super();
22
+ }
23
+ async run(_passedParams, options) {
24
+ return this.deploy(options);
25
+ }
26
+ parseFile(val) {
27
+ return val;
28
+ }
29
+ async deploy(options) {
30
+ if (!(0, utils_1.isProjectRoot)()) {
31
+ console.error((0, chalk_1.red)(`Please run this command in the root directory of the project.`));
32
+ (0, process_1.exit)(-1);
33
+ }
34
+ if (options.file && !(0, fs_1.existsSync)(options.file)) {
35
+ console.error((0, chalk_1.red)(`Deploy script "${options.file}" not found.`));
36
+ (0, process_1.exit)(-1);
37
+ }
38
+ // TODO: If private key was generated just now, then exit.
39
+ await (0, utils_1.stepCmd)('Generating private key', 'npm run genprivkey');
40
+ // Run deploy script.
41
+ try {
42
+ let deployScriptPath = options.file ? options.file : (0, path_1.join)('.', 'deploy.ts');
43
+ if (!(0, fs_1.existsSync)(deployScriptPath)) {
44
+ deployScriptPath = (0, path_1.join)('.', 'scripts', 'deploy.ts');
45
+ }
46
+ // Check if script exists, if not, create one.
47
+ if (!(0, fs_1.existsSync)(deployScriptPath)) {
48
+ console.error((0, chalk_1.red)(`Not deploy script found.`));
49
+ (0, process_1.exit)(-1);
50
+ }
51
+ console.log((0, chalk_1.green)(`Running deployment script "${deployScriptPath}"...`));
52
+ await (0, utils_1.shExec)(`npx tsx ${deployScriptPath}`);
53
+ }
54
+ catch (e) {
55
+ console.error((0, chalk_1.red)(`Running deployment script "${options.file}" failed, ${e}`));
56
+ (0, process_1.exit)(-1);
57
+ }
58
+ (0, process_1.exit)(0);
59
+ }
60
+ };
61
+ exports.DeployCommand = DeployCommand;
62
+ __decorate([
63
+ (0, nest_commander_1.Option)({
64
+ flags: '-f, --file [file]',
65
+ required: true,
66
+ description: 'Path to deployment script. Defaults to "deploy.ts" if none specified.',
67
+ }),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", [String]),
70
+ __metadata("design:returntype", String)
71
+ ], DeployCommand.prototype, "parseFile", null);
72
+ exports.DeployCommand = DeployCommand = __decorate([
73
+ (0, nest_commander_1.Command)({
74
+ name: 'deploy',
75
+ description: 'Deploy a smart contract',
76
+ }),
77
+ __metadata("design:paramtypes", [])
78
+ ], DeployCommand);
79
+ //# sourceMappingURL=deploy.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.command.js","sourceRoot":"","sources":["../../src/commands/deploy.command.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgE;AAChE,2CAAiE;AACjE,iCAAmC;AACnC,qCAA+B;AAC/B,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gBAAgB,CAAC,EAAE,CAAC;gBAClC,OAAO,CAAC,KAAK,CAAC,IAAA,WAAG,EAAC,0BAA0B,CAAC,CAAC,CAAC;gBAC/C,IAAA,cAAI,EAAC,CAAC,CAAC,CAAC,CAAC;YACX,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,IAAA,aAAK,EAAC,8BAA8B,gBAAgB,MAAM,CAAC,CAAC,CAAC;YAEzE,MAAM,IAAA,cAAM,EAAC,WAAW,gBAAgB,EAAE,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,IAAA,WAAG,EAAC,8BAA8B,OAAO,CAAC,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAA,cAAI,EAAC,CAAC,CAAC,CAAC,CAAC;QACX,CAAC;QAED,IAAA,cAAI,EAAC,CAAC,CAAC,CAAC;IACV,CAAC;CACF,CAAA;AAxDY,sCAAa;AAcxB;IALC,IAAA,uBAAM,EAAC;QACN,KAAK,EAAE,mBAAmB;QAC1B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,uEAAuE;KACrF,CAAC;;;;8CAGD;wBAhBU,aAAa;IAJzB,IAAA,wBAAO,EAAC;QACP,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,yBAAyB;KACvC,CAAC;;GACW,aAAa,CAwDzB"}
@@ -0,0 +1,11 @@
1
+ import { CommandRunner } from 'nest-commander';
2
+ import { ProjectCommandOptions } from './project';
3
+ export declare class ProjectCommand extends CommandRunner {
4
+ constructor();
5
+ run(passedParams: string[], options?: ProjectCommandOptions): Promise<void>;
6
+ parseStateful(_val: string): boolean;
7
+ parseLibrary(_val: string): boolean;
8
+ parseAsm(_val: string): boolean;
9
+ parseMinimal(_val: string): boolean;
10
+ }
11
+ //# sourceMappingURL=project.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.command.d.ts","sourceRoot":"","sources":["../../src/commands/project.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAW,qBAAqB,EAAe,MAAM,WAAW,CAAC;AAExE,qBAKa,cAAe,SAAQ,aAAa;;IAKzC,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBjF,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQpC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQnC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQ/B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGpC"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ProjectCommand = void 0;
13
+ const nest_commander_1 = require("nest-commander");
14
+ const chalk_1 = require("chalk");
15
+ const project_1 = require("./project");
16
+ let ProjectCommand = class ProjectCommand extends nest_commander_1.CommandRunner {
17
+ constructor() {
18
+ super();
19
+ }
20
+ async run(passedParams, options) {
21
+ if (options.state && options.lib) {
22
+ console.log((0, chalk_1.red)('Flags "--state" and "--lib" cannot be used together.'));
23
+ return;
24
+ }
25
+ const [name] = passedParams;
26
+ if (options.state) {
27
+ await (0, project_1.project)(project_1.ProjectType.StatefulContract, options, name);
28
+ }
29
+ else if (options.lib) {
30
+ await (0, project_1.project)(project_1.ProjectType.Library, options, name);
31
+ }
32
+ else {
33
+ await (0, project_1.project)(project_1.ProjectType.Contract, options, name);
34
+ }
35
+ }
36
+ parseStateful(_val) {
37
+ return true;
38
+ }
39
+ parseLibrary(_val) {
40
+ return true;
41
+ }
42
+ parseAsm(_val) {
43
+ return true;
44
+ }
45
+ parseMinimal(_val) {
46
+ return true;
47
+ }
48
+ };
49
+ exports.ProjectCommand = ProjectCommand;
50
+ __decorate([
51
+ (0, nest_commander_1.Option)({
52
+ flags: '-s, --state [state]',
53
+ description: 'Create stateful smart contract project',
54
+ }),
55
+ __metadata("design:type", Function),
56
+ __metadata("design:paramtypes", [String]),
57
+ __metadata("design:returntype", Boolean)
58
+ ], ProjectCommand.prototype, "parseStateful", null);
59
+ __decorate([
60
+ (0, nest_commander_1.Option)({
61
+ flags: '-l, --lib [lib]',
62
+ description: 'Create library project',
63
+ }),
64
+ __metadata("design:type", Function),
65
+ __metadata("design:paramtypes", [String]),
66
+ __metadata("design:returntype", Boolean)
67
+ ], ProjectCommand.prototype, "parseLibrary", null);
68
+ __decorate([
69
+ (0, nest_commander_1.Option)({
70
+ flags: '--asm [asm]',
71
+ description: 'Include inline ASM script',
72
+ }),
73
+ __metadata("design:type", Function),
74
+ __metadata("design:paramtypes", [String]),
75
+ __metadata("design:returntype", Boolean)
76
+ ], ProjectCommand.prototype, "parseAsm", null);
77
+ __decorate([
78
+ (0, nest_commander_1.Option)({
79
+ flags: '--min [min]',
80
+ description: 'Include only minimal dependencies and configs',
81
+ }),
82
+ __metadata("design:type", Function),
83
+ __metadata("design:paramtypes", [String]),
84
+ __metadata("design:returntype", Boolean)
85
+ ], ProjectCommand.prototype, "parseMinimal", null);
86
+ exports.ProjectCommand = ProjectCommand = __decorate([
87
+ (0, nest_commander_1.Command)({
88
+ name: 'project',
89
+ arguments: '<name>',
90
+ description: 'Create a new smart contract project',
91
+ }),
92
+ __metadata("design:paramtypes", [])
93
+ ], ProjectCommand);
94
+ //# sourceMappingURL=project.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.command.js","sourceRoot":"","sources":["../../src/commands/project.command.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgE;AAChE,iCAA4B;AAC5B,uCAAwE;AAOjE,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,8BAAa;IAC/C;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,YAAsB,EAAE,OAA+B;QAC/D,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAG,EAAC,sDAAsD,CAAC,CAAC,CAAC;YACzE,OAAO;QACT,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;QAE5B,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,IAAA,iBAAO,EAAC,qBAAW,CAAC,gBAAgB,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC;aAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACvB,MAAM,IAAA,iBAAO,EAAC,qBAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,MAAM,IAAA,iBAAO,EAAC,qBAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAMD,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAMD,YAAY,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAMD,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAMD,YAAY,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AArDY,wCAAc;AA0BzB;IAJC,IAAA,uBAAM,EAAC;QACN,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EAAE,wCAAwC;KACtD,CAAC;;;;mDAGD;AAMD;IAJC,IAAA,uBAAM,EAAC;QACN,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,wBAAwB;KACtC,CAAC;;;;kDAGD;AAMD;IAJC,IAAA,uBAAM,EAAC;QACN,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,2BAA2B;KACzC,CAAC;;;;8CAGD;AAMD;IAJC,IAAA,uBAAM,EAAC;QACN,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,+CAA+C;KAC7D,CAAC;;;;kDAGD;yBApDU,cAAc;IAL1B,IAAA,wBAAO,EAAC;QACP,IAAI,EAAE,SAAS;QACf,SAAS,EAAE,QAAQ;QACnB,WAAW,EAAE,qCAAqC;KACnD,CAAC;;GACW,cAAc,CAqD1B"}
@@ -0,0 +1,24 @@
1
+ export interface ProjectCommandOptions {
2
+ state?: boolean;
3
+ lib?: boolean;
4
+ asm?: boolean;
5
+ }
6
+ export declare enum ProjectType {
7
+ Contract = 0,
8
+ Library = 1,
9
+ StatefulContract = 2
10
+ }
11
+ export declare const PROJECT_NAME_TEMPLATE = "PROJECT_NAME";
12
+ export declare const PROJECT_FILENAME_TEMPLATE = "PROJECT_FILENAME";
13
+ export declare const PROJECT_PACKAGE_NAME_TEMPLATE = "package-name";
14
+ /**
15
+ * Create a new sCrypt project with recommended dir structure, Prettier config,
16
+ * testing lib, etc. Warns if already exists and does NOT overwrite.
17
+ * @param {string} projType - The user's desired project type.
18
+ * @param {object} argv - The arguments object provided by yargs.
19
+ * @param {string} argv.asm - Add .asm dir to project.
20
+ * @param {string} argv.name - The user's desired project name.
21
+ * @return {Promise<void>}
22
+ */
23
+ export declare function project(projType: any, options: ProjectCommandOptions, name: string): Promise<void>;
24
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/commands/project.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,oBAAY,WAAW;IACrB,QAAQ,IAAA;IACR,OAAO,IAAA;IACP,gBAAgB,IAAA;CACjB;AAED,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AACpD,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAE5D,eAAO,MAAM,6BAA6B,iBAAiB,CAAC;AAE5D;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,QAAQ,KAAA,EAAE,OAAO,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,iBAyEnF"}
@@ -0,0 +1,217 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.project = exports.PROJECT_PACKAGE_NAME_TEMPLATE = exports.PROJECT_FILENAME_TEMPLATE = exports.PROJECT_NAME_TEMPLATE = exports.ProjectType = void 0;
30
+ const ora_1 = __importDefault(require("ora"));
31
+ const process_1 = require("process");
32
+ const fs_1 = require("fs");
33
+ const sh = __importStar(require("shelljs"));
34
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
35
+ const { version } = require('../../package.json');
36
+ const utils_1 = require("../common/utils");
37
+ const path_1 = require("path");
38
+ const chalk_1 = require("chalk");
39
+ var ProjectType;
40
+ (function (ProjectType) {
41
+ ProjectType[ProjectType["Contract"] = 0] = "Contract";
42
+ ProjectType[ProjectType["Library"] = 1] = "Library";
43
+ ProjectType[ProjectType["StatefulContract"] = 2] = "StatefulContract";
44
+ })(ProjectType || (exports.ProjectType = ProjectType = {}));
45
+ exports.PROJECT_NAME_TEMPLATE = 'PROJECT_NAME';
46
+ exports.PROJECT_FILENAME_TEMPLATE = 'PROJECT_FILENAME';
47
+ exports.PROJECT_PACKAGE_NAME_TEMPLATE = 'package-name';
48
+ /**
49
+ * Create a new sCrypt project with recommended dir structure, Prettier config,
50
+ * testing lib, etc. Warns if already exists and does NOT overwrite.
51
+ * @param {string} projType - The user's desired project type.
52
+ * @param {object} argv - The arguments object provided by yargs.
53
+ * @param {string} argv.asm - Add .asm dir to project.
54
+ * @param {string} argv.name - The user's desired project name.
55
+ * @return {Promise<void>}
56
+ */
57
+ async function project(projType, options, name) {
58
+ if (name.search(/[^-0-9a-zA-Z]/g) != -1) {
59
+ console.error((0, chalk_1.red)(`Invalid project name format`));
60
+ (0, process_1.exit)(-1);
61
+ }
62
+ if ((0, fs_1.existsSync)(name)) {
63
+ console.error((0, chalk_1.red)(`Directory already exists. Not proceeding`));
64
+ (0, process_1.exit)(-1);
65
+ }
66
+ // Git must be initialized before running `npm install` b/c Husky runs an
67
+ // NPM `prepare` script to set up its pre-commit hook within `.git`.
68
+ // Check before fetching project template, to not leave crud on user's system.
69
+ if (!sh.which('git')) {
70
+ console.error((0, chalk_1.red)('Please ensure Git is installed, then try again.'));
71
+ (0, process_1.exit)(-1);
72
+ }
73
+ // Create path/to/dir with their desired name
74
+ if (sh.mkdir('-p', name).code != 0) {
75
+ (0, process_1.exit)(-1);
76
+ }
77
+ sh.cd(name); // Set dir for shell commands. Doesn't change user's dir in their CLI.
78
+ // Initialize .git in the root, whether monorepo or not.
79
+ await (0, utils_1.stepCmd)('Initialize Git repo', 'git init -q');
80
+ if (projType == ProjectType.Contract) {
81
+ if (!(await fetchProjectTemplate('demo-contract')))
82
+ return;
83
+ }
84
+ else if (projType == ProjectType.Library) {
85
+ if (!(await fetchProjectTemplate('demo-lib')))
86
+ return;
87
+ }
88
+ else if (projType == ProjectType.StatefulContract) {
89
+ if (!(await fetchProjectTemplate('counter')))
90
+ return;
91
+ }
92
+ else {
93
+ (0, process_1.exit)(-1);
94
+ }
95
+ // `/dev/null` on Mac or Linux and 'NUL' on Windows is the only way to silence
96
+ // Husky's install log msg. (Note: The contract project template commits
97
+ // package-lock.json so we can use `npm ci` for faster installation.)
98
+ //await stepCmd(
99
+ // 'NPM install',
100
+ // `npm ci --silent > ${isWindows ? 'NUL' : '"/dev/null" 2>&1'}`
101
+ //);
102
+ //// Build the template contract so it can be imported into the ui scaffold
103
+ //await stepCmd('NPM build contract', 'npm run build --silent');
104
+ await setProjectName('.', name.split(path_1.sep).pop());
105
+ // `-n` (no verify) skips Husky's pre-commit hooks.
106
+ //await stepCmd(
107
+ // 'Git init commit',
108
+ // 'git add . && git commit -m "Init commit" -q -n && git branch -m main'
109
+ //);
110
+ //
111
+ await configurePackageJson('.', options.asm);
112
+ if (options.asm) {
113
+ await (0, utils_1.createAsmDir)();
114
+ }
115
+ let resStr = `\nProject ${name} was successfully created!`;
116
+ resStr +=
117
+ `\n\nAdd your Git repo URL and you're good to go:` +
118
+ `\ncd ${name} && git remote add origin <your-repo-url>`;
119
+ console.log((0, chalk_1.green)(resStr));
120
+ (0, process_1.exit)(0);
121
+ }
122
+ exports.project = project;
123
+ /**
124
+ * Fetch project template.
125
+ * @returns {Promise<boolean>} - True if successful; false if not.
126
+ */
127
+ async function fetchProjectTemplate(projectName) {
128
+ const step = 'Set up project';
129
+ const spin = (0, ora_1.default)({ text: `${step}...`, discardStdin: true }).start();
130
+ try {
131
+ await (0, utils_1.unTarTemplates)(projectName, '.');
132
+ spin.succeed((0, chalk_1.green)(step));
133
+ return true;
134
+ }
135
+ catch (err) {
136
+ spin.fail(step);
137
+ console.error(err);
138
+ return false;
139
+ }
140
+ }
141
+ /**
142
+ * Step to replace placeholder names in the project with the properly-formatted
143
+ * version of the user-supplied name as specified via `zk project <name>`
144
+ * @param {string} dir - Path to the dir containing target files to be changed.
145
+ * @param {string} name - User-provided project name.
146
+ * @returns {Promise<void>}
147
+ */
148
+ async function setProjectName(dir, name) {
149
+ const step = 'Set project name';
150
+ const spin = (0, ora_1.default)(`${step}...`).start();
151
+ (0, utils_1.replaceInFile)((0, path_1.join)(dir, 'README.md'), exports.PROJECT_NAME_TEMPLATE, (0, utils_1.titleCase)(name));
152
+ (0, utils_1.replaceInFile)((0, path_1.join)(dir, 'package.json'), exports.PROJECT_PACKAGE_NAME_TEMPLATE, (0, utils_1.kebabCase)(name));
153
+ // Rename contract and test files w project name.
154
+ // Also rename template inside these files.
155
+ const dirSrc = (0, path_1.join)(dir, 'src');
156
+ const fIndex = (0, path_1.join)(dirSrc, 'index.ts');
157
+ if ((0, fs_1.existsSync)(fIndex)) {
158
+ (0, utils_1.replaceInFile)(fIndex, exports.PROJECT_FILENAME_TEMPLATE, (0, utils_1.camelCase)(name));
159
+ (0, utils_1.replaceInFile)(fIndex, exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCaseCapitalized)(name));
160
+ }
161
+ const dirContracts = (0, path_1.join)(dirSrc, 'contracts');
162
+ const fContract = (0, path_1.join)(dirContracts, exports.PROJECT_NAME_TEMPLATE + '.ts');
163
+ const fContractNew = fContract.replace(exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCase)(name));
164
+ if ((0, fs_1.existsSync)(fContract)) {
165
+ sh.mv(fContract, fContractNew);
166
+ (0, utils_1.replaceInFile)(fContractNew, exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCaseCapitalized)(name));
167
+ }
168
+ const ftestContract = (0, path_1.join)(dirContracts, 'test' + exports.PROJECT_NAME_TEMPLATE + '.ts');
169
+ const ftestContractNew = ftestContract.replace(exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCase)(name));
170
+ if ((0, fs_1.existsSync)(ftestContract)) {
171
+ sh.mv(ftestContract, ftestContractNew);
172
+ (0, utils_1.replaceInFile)(ftestContractNew, exports.PROJECT_FILENAME_TEMPLATE, (0, utils_1.camelCase)(name));
173
+ (0, utils_1.replaceInFile)(ftestContractNew, exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCaseCapitalized)(name));
174
+ }
175
+ const dirTests = (0, path_1.join)(dir, 'tests');
176
+ const fTest = (0, path_1.join)(dirTests, exports.PROJECT_NAME_TEMPLATE + '.test.ts');
177
+ const fTestNew = fTest.replace(exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCase)(name));
178
+ if ((0, fs_1.existsSync)(fTest)) {
179
+ sh.mv(fTest, fTestNew);
180
+ (0, utils_1.replaceInFile)(fTestNew, exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCaseCapitalized)(name));
181
+ (0, utils_1.replaceInFile)(fTestNew, exports.PROJECT_PACKAGE_NAME_TEMPLATE, (0, utils_1.kebabCase)(name));
182
+ }
183
+ const fDeployScript = (0, path_1.join)(dir, 'deploy.ts');
184
+ if ((0, fs_1.existsSync)(fDeployScript)) {
185
+ (0, utils_1.replaceInFile)(fDeployScript, exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCaseCapitalized)(name));
186
+ (0, utils_1.replaceInFile)(fDeployScript, exports.PROJECT_PACKAGE_NAME_TEMPLATE, (0, utils_1.kebabCase)(name));
187
+ }
188
+ const importTemplateLaunch = `${exports.PROJECT_NAME_TEMPLATE}`;
189
+ const importReplacementLaunch = importTemplateLaunch.replace(exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCase)(name));
190
+ const fLaunch = (0, path_1.join)(dir, '.vscode', 'launch.json');
191
+ if ((0, fs_1.existsSync)(fLaunch)) {
192
+ (0, utils_1.replaceInFile)(fLaunch, importTemplateLaunch, importReplacementLaunch);
193
+ (0, utils_1.replaceInFile)(fLaunch, exports.PROJECT_NAME_TEMPLATE, (0, utils_1.camelCaseCapitalized)(name));
194
+ }
195
+ spin.succeed((0, chalk_1.green)(step));
196
+ }
197
+ /**
198
+ * Apply modifications to package.json if needed.
199
+ * @param {string} dir - Path to the dir containing target files to be changed.
200
+ * @param {string} asm - Configure for ASM optimizations.
201
+ * @param {string} minimal - Use minimal config. Defaults to false.
202
+ * @returns {Promise<boolean>} - True if successful; false if not.
203
+ */
204
+ async function configurePackageJson(dir, asm) {
205
+ const step = 'Configure package.json ';
206
+ const spin = (0, ora_1.default)(`${step}...`).start();
207
+ const packageJsonPath = (0, path_1.join)(dir, 'package.json');
208
+ const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath).toString());
209
+ // lock @scyrpt-inc/cli-opcat version
210
+ packageJson.scripts['compile'] = 'npx -y @opcat-labs/cli-opcat@' + version + ' compile';
211
+ if (asm) {
212
+ packageJson.scripts['compile'] += ' --asm';
213
+ }
214
+ (0, utils_1.writefile)(packageJsonPath, packageJson);
215
+ spin.succeed((0, chalk_1.green)(step));
216
+ }
217
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/commands/project.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB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AAC,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { CommandRunner } from 'nest-commander';
2
+ export declare class SystemCommand extends CommandRunner {
3
+ constructor();
4
+ run(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=system.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.command.d.ts","sourceRoot":"","sources":["../../src/commands/system.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGxD,qBAIa,aAAc,SAAQ,aAAa;;IAKxC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAc3B"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SystemCommand = void 0;
16
+ const nest_commander_1 = require("nest-commander");
17
+ const envinfo_1 = __importDefault(require("envinfo"));
18
+ let SystemCommand = class SystemCommand extends nest_commander_1.CommandRunner {
19
+ constructor() {
20
+ super();
21
+ }
22
+ async run() {
23
+ console.log('Please include the following when submitting a Github issue:');
24
+ envinfo_1.default
25
+ .run({
26
+ System: ['OS', 'CPU'],
27
+ Binaries: ['Node', 'Yarn', 'npm'],
28
+ npmPackages: ['@opcat-labs/scrypt-ts-transpiler-opcat', '@opcat-labs/scrypt-ts-opcat'],
29
+ }, { showNotFound: true })
30
+ .then((env) => console.log(env));
31
+ }
32
+ };
33
+ exports.SystemCommand = SystemCommand;
34
+ exports.SystemCommand = SystemCommand = __decorate([
35
+ (0, nest_commander_1.Command)({
36
+ name: 'system',
37
+ description: 'Show system info',
38
+ }),
39
+ __metadata("design:paramtypes", [])
40
+ ], SystemCommand);
41
+ //# sourceMappingURL=system.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.command.js","sourceRoot":"","sources":["../../src/commands/system.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAwD;AACxD,sDAA8B;AAMvB,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,8BAAa;IAC9C;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,KAAK,CAAC,GAAG;QACP,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;QAE5E,iBAAO;aACJ,GAAG,CACF;YACE,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;YACrB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;YACjC,WAAW,EAAE,CAAC,wCAAwC,EAAE,6BAA6B,CAAC;SACvF,EACD,EAAE,YAAY,EAAE,IAAI,EAAE,CACvB;aACA,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AAnBY,sCAAa;wBAAb,aAAa;IAJzB,IAAA,wBAAO,EAAC;QACP,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,kBAAkB;KAChC,CAAC;;GACW,aAAa,CAmBzB"}
@@ -0,0 +1,6 @@
1
+ import { CommandRunner } from 'nest-commander';
2
+ export declare class VersionCommand extends CommandRunner {
3
+ constructor();
4
+ run(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=version.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.command.d.ts","sourceRoot":"","sources":["../../src/commands/version.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIxD,qBAIa,cAAe,SAAQ,aAAa;;IAKzC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAG3B"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.VersionCommand = void 0;
13
+ const nest_commander_1 = require("nest-commander");
14
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
15
+ const { version } = require('../../package.json');
16
+ let VersionCommand = class VersionCommand extends nest_commander_1.CommandRunner {
17
+ constructor() {
18
+ super();
19
+ }
20
+ async run() {
21
+ console.log(`v${version}`);
22
+ }
23
+ };
24
+ exports.VersionCommand = VersionCommand;
25
+ exports.VersionCommand = VersionCommand = __decorate([
26
+ (0, nest_commander_1.Command)({
27
+ name: 'version',
28
+ description: 'Output the version number',
29
+ }),
30
+ __metadata("design:paramtypes", [])
31
+ ], VersionCommand);
32
+ //# sourceMappingURL=version.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.command.js","sourceRoot":"","sources":["../../src/commands/version.command.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAwD;AACxD,iEAAiE;AACjE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAM3C,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,8BAAa;IAC/C;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,KAAK,CAAC,GAAG;QACP,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AARY,wCAAc;yBAAd,cAAc;IAJ1B,IAAA,wBAAO,EAAC;QACP,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,2BAA2B;KACzC,CAAC;;GACW,cAAc,CAQ1B"}
@@ -0,0 +1,68 @@
1
+ import { GlobOptions } from 'glob';
2
+ export declare const shExec: Function;
3
+ export declare function shExecWithoutOutput(command: string): Promise<string>;
4
+ export declare function readdirRecursive(dir: string): Promise<string[]>;
5
+ /**
6
+ * Helper for any steps for a consistent UX.
7
+ * @template T
8
+ * @param {string} step Name of step to show user.
9
+ * @param {() => Promise<T>} fn An async function to execute.
10
+ * @returns {Promise<T>}
11
+ */
12
+ export declare function step<T>(str: string, fn: () => Promise<T>): Promise<T>;
13
+ /**
14
+ * Helper for any steps that need to call a shell command.
15
+ * @param {string} step - Name of step to show user
16
+ * @param {string} cmd - Shell command to execute.
17
+ * @returns {Promise<string>}
18
+ */
19
+ export declare function stepCmd(step: string, cmd: string, exitOnError?: boolean): Promise<string | Error>;
20
+ /**
21
+ * Helper to replace text in a file.
22
+ * @param {string} file - Path to file
23
+ * @param {string} a - Old text.
24
+ * @param {string} b - New text.
25
+ */
26
+ export declare function replaceInFile(file: string, a: string, b: string): void;
27
+ /**
28
+ * Helper to read a JSON file
29
+ * @param {string} file
30
+ * @param {boolean} if returns json format
31
+ * @returns
32
+ */
33
+ export declare function readfile<T>(file: string, json?: boolean): T | string;
34
+ /**
35
+ * Helper to write a JSON object to a file
36
+ * @param {string} path - Path of file
37
+ * @param {object | string} content - Object or text to save
38
+ */
39
+ export declare function writefile(file: string, content: object | string): void;
40
+ /**
41
+ * Helper function to delete a file or directory.
42
+ * @param {string} itemPath Path to the file or directory to delete.
43
+ */
44
+ export declare function deletefile(itemPath: string): void;
45
+ /**
46
+ * Helper to change file extension in a path
47
+ * @param {string} file - The path of a file
48
+ * @param {string} extension
49
+ * @returns {string}
50
+ */
51
+ export declare function changeExtension(file: string, extension: string): string;
52
+ /**
53
+ * Read config in src/configs
54
+ * @param {string} config Filename
55
+ * @returns
56
+ */
57
+ export declare function readAsset(filename: string): string;
58
+ export declare function writeAsset(absolutePath: string, assetFileName?: string): void;
59
+ export declare function isProjectRoot(): boolean;
60
+ export declare function titleCase(str: string): string;
61
+ export declare function kebabCase(str: string): string;
62
+ export declare function camelCase(str: string): string;
63
+ export declare function camelCaseCapitalized(str: string): string;
64
+ export declare function resolvePaths(patterns: string[], options?: GlobOptions): string[];
65
+ export declare function extractBaseNames(input: string[]): string[];
66
+ export declare function createAsmDir(): Promise<void>;
67
+ export declare function unTarTemplates(projectName: string, outDir: string): Promise<void>;
68
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAQ,WAAW,EAAE,MAAM,MAAM,CAAC;AAQzC,eAAO,MAAM,MAAM,UAA0B,CAAC;AAE9C,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUpE;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAYrE;AAED;;;;;;GAMG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAA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