opticore-cli 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.
- package/dist/index.cjs +108 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +85 -0
- package/package.json +41 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var import_child_process2 = require("child_process");
|
|
28
|
+
|
|
29
|
+
// src/commands/generate.command.ts
|
|
30
|
+
var path = __toESM(require("path"), 1);
|
|
31
|
+
var fs = __toESM(require("fs"), 1);
|
|
32
|
+
var import_child_process = require("child_process");
|
|
33
|
+
var generate = (type, name) => {
|
|
34
|
+
const basePath = process.cwd();
|
|
35
|
+
let targetDir = "";
|
|
36
|
+
let content = "";
|
|
37
|
+
switch (type) {
|
|
38
|
+
case "service":
|
|
39
|
+
break;
|
|
40
|
+
case "component":
|
|
41
|
+
if (!name) {
|
|
42
|
+
console.error("\u274C Please specify the component name");
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
console.log(`Component generation ${name}...`);
|
|
46
|
+
const result = (0, import_child_process.spawnSync)("npx", ["create-clean-component", name], {
|
|
47
|
+
stdio: "inherit",
|
|
48
|
+
shell: true
|
|
49
|
+
});
|
|
50
|
+
if (result.error) {
|
|
51
|
+
console.error("\u274C Error generating component :", result.error.message);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
console.error("\u274C Unsupported type!");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!fs.existsSync(targetDir)) {
|
|
59
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
const filePath = path.join(targetDir, `${name}.${type}.ts`);
|
|
62
|
+
fs.writeFileSync(filePath, content);
|
|
63
|
+
console.log(`\u2705 ${type} ${name} created in ${filePath}`);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/index.ts
|
|
67
|
+
var main = () => {
|
|
68
|
+
const args = process.argv.slice(2);
|
|
69
|
+
const program = args[0];
|
|
70
|
+
switch (program) {
|
|
71
|
+
case "new":
|
|
72
|
+
const projectName = args[1];
|
|
73
|
+
if (!projectName) {
|
|
74
|
+
console.error("\u274C The project name must get a name");
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
console.log(`Project creation ${projectName}...`);
|
|
78
|
+
const result = (0, import_child_process2.spawnSync)("npx", ["opticore-new-project", projectName], {
|
|
79
|
+
stdio: "inherit",
|
|
80
|
+
shell: true
|
|
81
|
+
});
|
|
82
|
+
if (result.error) {
|
|
83
|
+
console.error("\u274C Error during installation :", result.error.message);
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case "generate":
|
|
87
|
+
case "g":
|
|
88
|
+
const type = args[1];
|
|
89
|
+
const name = args[2];
|
|
90
|
+
if (!type || !name) {
|
|
91
|
+
console.error("\u274C Usage : opticore generate <type> <name>");
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
generate(type, name);
|
|
95
|
+
break;
|
|
96
|
+
case "help":
|
|
97
|
+
default:
|
|
98
|
+
console.log(`
|
|
99
|
+
OptiCore CLI
|
|
100
|
+
Available commands :
|
|
101
|
+
opticore new <projectName> Create a new project
|
|
102
|
+
opticore generate <type> <name> Generate an artifact (service, component, etc.)
|
|
103
|
+
opticore help Get help for a specific command with OptiCoreJs help COMMAND.
|
|
104
|
+
`);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
main();
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
5
|
+
|
|
6
|
+
// src/commands/generate.command.ts
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import { spawnSync } from "child_process";
|
|
10
|
+
var generate = (type, name) => {
|
|
11
|
+
const basePath = process.cwd();
|
|
12
|
+
let targetDir = "";
|
|
13
|
+
let content = "";
|
|
14
|
+
switch (type) {
|
|
15
|
+
case "service":
|
|
16
|
+
break;
|
|
17
|
+
case "component":
|
|
18
|
+
if (!name) {
|
|
19
|
+
console.error("\u274C Please specify the component name");
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
console.log(`Component generation ${name}...`);
|
|
23
|
+
const result = spawnSync("npx", ["create-clean-component", name], {
|
|
24
|
+
stdio: "inherit",
|
|
25
|
+
shell: true
|
|
26
|
+
});
|
|
27
|
+
if (result.error) {
|
|
28
|
+
console.error("\u274C Error generating component :", result.error.message);
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
console.error("\u274C Unsupported type!");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!fs.existsSync(targetDir)) {
|
|
36
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
const filePath = path.join(targetDir, `${name}.${type}.ts`);
|
|
39
|
+
fs.writeFileSync(filePath, content);
|
|
40
|
+
console.log(`\u2705 ${type} ${name} created in ${filePath}`);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/index.ts
|
|
44
|
+
var main = () => {
|
|
45
|
+
const args = process.argv.slice(2);
|
|
46
|
+
const program = args[0];
|
|
47
|
+
switch (program) {
|
|
48
|
+
case "new":
|
|
49
|
+
const projectName = args[1];
|
|
50
|
+
if (!projectName) {
|
|
51
|
+
console.error("\u274C The project name must get a name");
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
console.log(`Project creation ${projectName}...`);
|
|
55
|
+
const result = spawnSync2("npx", ["opticore-new-project", projectName], {
|
|
56
|
+
stdio: "inherit",
|
|
57
|
+
shell: true
|
|
58
|
+
});
|
|
59
|
+
if (result.error) {
|
|
60
|
+
console.error("\u274C Error during installation :", result.error.message);
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case "generate":
|
|
64
|
+
case "g":
|
|
65
|
+
const type = args[1];
|
|
66
|
+
const name = args[2];
|
|
67
|
+
if (!type || !name) {
|
|
68
|
+
console.error("\u274C Usage : opticore generate <type> <name>");
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
generate(type, name);
|
|
72
|
+
break;
|
|
73
|
+
case "help":
|
|
74
|
+
default:
|
|
75
|
+
console.log(`
|
|
76
|
+
OptiCore CLI
|
|
77
|
+
Available commands :
|
|
78
|
+
opticore new <projectName> Create a new project
|
|
79
|
+
opticore generate <type> <name> Generate an artifact (service, component, etc.)
|
|
80
|
+
opticore help Get help for a specific command with OptiCoreJs help COMMAND.
|
|
81
|
+
`);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opticore-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"opticore": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
16
|
+
"dev": "ts-node src/index.ts",
|
|
17
|
+
"build": "tsup",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/guyzoum77/opticore-cli.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"opticore-cli",
|
|
26
|
+
"opticore",
|
|
27
|
+
"opticore-installer"
|
|
28
|
+
],
|
|
29
|
+
"author": "Guy-serge Kouacou",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/guyzoum77/opticore-cli/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/guyzoum77/opticore-cli#readme",
|
|
35
|
+
"description": "",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"ts-node": "^10.9.2",
|
|
38
|
+
"tsup": "^8.5.0",
|
|
39
|
+
"typescript": "^5.9.2"
|
|
40
|
+
}
|
|
41
|
+
}
|