@unisphere/cli 1.20.1 → 1.20.3
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/package.json +1 -1
- package/src/index.js +2 -2
- package/src/index.js.map +1 -1
- package/src/lib/commands/create/command.d.ts +2 -0
- package/src/lib/commands/create/command.js +84 -0
- package/src/lib/commands/create/command.js.map +1 -0
- package/src/lib/unisphere.js +3 -0
- package/src/lib/unisphere.js.map +1 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const unisphere = require("./lib/unisphere");
|
|
6
|
-
//
|
|
6
|
+
// 2
|
|
7
7
|
(function () {
|
|
8
8
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
9
|
yield unisphere();
|
|
10
10
|
});
|
|
11
|
-
}()
|
|
11
|
+
})();
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/unisphere-cli/src/index.ts"],"names":[],"mappings":";;;;AAEA,6CAA6C;AAC7C,IAAI;AACJ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/unisphere-cli/src/index.ts"],"names":[],"mappings":";;;;AAEA,6CAA6C;AAC7C,IAAI;AACJ,CAAC;;QACC,MAAM,SAAS,EAAE,CAAC;IACpB,CAAC;CAAA,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCreateCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const debug_1 = require("debug");
|
|
7
|
+
const listr2_1 = require("listr2");
|
|
8
|
+
const utils_1 = require("../../utils/utils");
|
|
9
|
+
const defaults_1 = require("../../utils/listr2/defaults");
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const child_process_1 = require("child_process");
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const debug = (0, debug_1.default)('unisphere:create');
|
|
14
|
+
const createCreateCommand = () => {
|
|
15
|
+
const command = new commander_1.Command('create');
|
|
16
|
+
command
|
|
17
|
+
.description('create a new unisphere project')
|
|
18
|
+
.argument('<widget-name>', 'The name of the widget project')
|
|
19
|
+
.option('--cwd <path>', 'The working directory', process.cwd())
|
|
20
|
+
.option('--verbose', 'Output debug logs', false)
|
|
21
|
+
.hook('preAction', utils_1.printVerboseHook)
|
|
22
|
+
.action((widgetName, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const cwd = (0, path_1.resolve)(options.cwd || process.cwd());
|
|
24
|
+
const formattedWidgetName = widgetName
|
|
25
|
+
.replace(/[\s-_]+/g, '') // Normalize widget name
|
|
26
|
+
.replace(/^./, (char) => char.toLowerCase()); // Lowercase first letter
|
|
27
|
+
const widgetPath = (0, path_1.resolve)(cwd, formattedWidgetName);
|
|
28
|
+
const templatesPath = (0, path_1.resolve)(__dirname, '../../../../../../_templates'); // Adjust this path based on your repo structure
|
|
29
|
+
debug(`Using templates from: ${templatesPath}`);
|
|
30
|
+
const tasks = [
|
|
31
|
+
{
|
|
32
|
+
title: 'Check if the working directory exists',
|
|
33
|
+
task: () => {
|
|
34
|
+
if (!(0, fs_1.existsSync)(cwd)) {
|
|
35
|
+
throw new Error(`Working directory "${cwd}" does not exist.`);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'Check if widget path exists',
|
|
41
|
+
task: () => {
|
|
42
|
+
if ((0, fs_1.existsSync)(widgetPath)) {
|
|
43
|
+
throw new Error(`Path "${widgetPath}" already exists.`);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
title: 'Create project folder',
|
|
49
|
+
task: () => {
|
|
50
|
+
(0, fs_1.mkdirSync)(widgetPath, { recursive: true });
|
|
51
|
+
debug(`Created project folder: ${widgetPath}`);
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: 'Generate project using Hygen',
|
|
56
|
+
task: () => {
|
|
57
|
+
try {
|
|
58
|
+
// Set HYGEN_TEMPLATES to use the custom templates directory
|
|
59
|
+
(0, child_process_1.execSync)(`HYGEN_TEMPLATES="${templatesPath}" npx hygen kme new --widgetName "${formattedWidgetName}" --cwd "${widgetPath}" --verbose`, { stdio: 'inherit' });
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw new Error(`Hygen execution failed: ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
// {
|
|
67
|
+
// title: 'Run npm install',
|
|
68
|
+
// task: () => {
|
|
69
|
+
// try {
|
|
70
|
+
// execSync('npm install', { cwd: widgetPath, stdio: 'inherit' });
|
|
71
|
+
// debug('Dependencies installed successfully.');
|
|
72
|
+
// } catch (error) {
|
|
73
|
+
// throw new Error(`npm install failed: ${error.message}`);
|
|
74
|
+
// }
|
|
75
|
+
// },
|
|
76
|
+
// },
|
|
77
|
+
];
|
|
78
|
+
const taskRunner = new listr2_1.Listr(tasks, (0, defaults_1.getDefaultListrOptions)());
|
|
79
|
+
yield taskRunner.run();
|
|
80
|
+
}));
|
|
81
|
+
return command;
|
|
82
|
+
};
|
|
83
|
+
exports.createCreateCommand = createCreateCommand;
|
|
84
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/create/command.ts"],"names":[],"mappings":";;;;AAAA,yCAAoC;AACpC,iCAA0B;AAC1B,mCA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mB,uBA4E9B"}
|
package/src/lib/unisphere.js
CHANGED
|
@@ -8,6 +8,7 @@ const { createCheckCommand } = require('./commands/check/command');
|
|
|
8
8
|
const { createHowToCommand } = require('./commands/how-to/command');
|
|
9
9
|
const { createLocalCommand } = require('./commands/local/local-command');
|
|
10
10
|
const { createResetCommand } = require('./commands/reset/command');
|
|
11
|
+
const { createCreateCommand } = require('./commands/create/command');
|
|
11
12
|
module.exports = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
13
|
const program = new Command();
|
|
13
14
|
program
|
|
@@ -22,6 +23,8 @@ module.exports = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
|
22
23
|
program.addCommand(createInitCommand());
|
|
23
24
|
program.addCommand(createLocalCommand());
|
|
24
25
|
program.addCommand(createResetCommand());
|
|
26
|
+
program.addCommand(createCreateCommand());
|
|
25
27
|
program.parse(process.argv);
|
|
26
28
|
});
|
|
29
|
+
// 1
|
|
27
30
|
//# sourceMappingURL=unisphere.js.map
|
package/src/lib/unisphere.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unisphere.js","sourceRoot":"","sources":["../../../../../packages/unisphere-cli/src/lib/unisphere.js"],"names":[],"mappings":";AAAA,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACzC,MAAM,EAAE,oBAAoB,EAAC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAA;AAC7E,MAAM,EAAE,oBAAoB,EAAC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAA;AAC7E,MAAM,EAAE,iBAAiB,EAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;AAC/D,MAAM,EAAE,iBAAiB,EAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;AAC/D,MAAM,EAAE,kBAAkB,EAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;AACjE,MAAM,EAAE,kBAAkB,EAAC,GAAG,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