@xrystal/core 3.6.5 → 3.6.7
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/bin/main-cli.js +16 -13
- package/package.json +1 -1
- package/source/loader/configs/index.d.ts +5 -8
- package/source/loader/configs/index.js +13 -12
- package/source/project/index.js +1 -2
package/bin/main-cli.js
CHANGED
|
@@ -56,18 +56,14 @@ const setupCLI = async () => {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
cli
|
|
59
|
-
.command("create <project-name>")
|
|
59
|
+
.command("create <project-name> [target-path]")
|
|
60
60
|
.description("Clone template from GitHub (Private/Public)")
|
|
61
|
-
.action(async (projectName) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
process.exit(1)
|
|
65
|
-
}
|
|
61
|
+
.action(async (projectName, targetDir) => {
|
|
62
|
+
const rawTarget = targetDir || (projectName === "." ? "." : projectName)
|
|
63
|
+
const targetPath = path.resolve(process.cwd(), rawTarget)
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (fs.existsSync(targetPath)) {
|
|
70
|
-
console.log(chalk.red(`❌ Error: '${projectName}' folder already exists!`))
|
|
65
|
+
if (fs.existsSync(targetPath) && fs.readdirSync(targetPath).length > 0) {
|
|
66
|
+
console.log(chalk.red(`❌ Error: Target directory '${targetPath}' is not empty!`))
|
|
71
67
|
process.exit(1)
|
|
72
68
|
}
|
|
73
69
|
|
|
@@ -82,20 +78,27 @@ const setupCLI = async () => {
|
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
spinner.succeed(chalk.green("Template cloned successfully!"))
|
|
85
|
-
console.log(chalk.blue(`\n📦 Dependencies loading with ${packageManager}
|
|
81
|
+
console.log(chalk.blue(`\n📦 Dependencies loading with ${packageManager}...`))
|
|
86
82
|
|
|
87
83
|
const installCmd = isBun ? "bun install" : "npm install"
|
|
88
84
|
execSync(installCmd, { cwd: targetPath, stdio: "inherit" })
|
|
89
85
|
|
|
90
86
|
console.log(chalk.green("\n✅ Project Ready!"))
|
|
91
87
|
console.log(chalk.white(`\nStart Project:\n`))
|
|
92
|
-
|
|
88
|
+
|
|
89
|
+
if (targetPath !== process.cwd()) {
|
|
90
|
+
console.log(chalk.cyan(` cd ${path.relative(process.cwd(), targetPath)}`))
|
|
91
|
+
}
|
|
92
|
+
|
|
93
93
|
console.log(chalk.cyan(` ${packageManager} run dev`))
|
|
94
94
|
|
|
95
95
|
} catch (err) {
|
|
96
96
|
spinner.fail(chalk.red("Failed to clone or install!"))
|
|
97
97
|
console.error(chalk.red(`\nError details: ${err.message}`))
|
|
98
|
-
|
|
98
|
+
|
|
99
|
+
if (fs.existsSync(targetPath) && targetPath !== process.cwd() && fs.readdirSync(targetPath).length === 0) {
|
|
100
|
+
fs.rmSync(targetPath, { recursive: true, force: true })
|
|
101
|
+
}
|
|
99
102
|
}
|
|
100
103
|
})
|
|
101
104
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import SystemService from '../system/index';
|
|
2
2
|
export default class ConfigsService {
|
|
3
|
-
|
|
3
|
+
private config;
|
|
4
4
|
protected _systemService: SystemService;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
load: ({ tmpFolderPath, systemService, envLoadPath, globalEnvFileName }: {
|
|
8
|
-
tmpFolderPath: string;
|
|
5
|
+
load: ({ tmp, systemService }: {
|
|
6
|
+
tmp: any;
|
|
9
7
|
systemService: SystemService;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}) => any;
|
|
8
|
+
}) => void;
|
|
9
|
+
get all(): Record<string, any>;
|
|
13
10
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
export default class ConfigsService {
|
|
2
|
-
|
|
2
|
+
config = {};
|
|
3
3
|
_systemService;
|
|
4
|
-
|
|
5
|
-
_envLoadPath = '';
|
|
6
|
-
load = ({ tmpFolderPath, systemService, envLoadPath, globalEnvFileName }) => {
|
|
7
|
-
ConfigsService.tmpFolderPath = tmpFolderPath;
|
|
4
|
+
load = ({ tmp, systemService }) => {
|
|
8
5
|
this._systemService = systemService;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
const rawConfigs = tmp?.configs || tmp?.configs || {};
|
|
7
|
+
this.config = {
|
|
8
|
+
rootFolderPath: rawConfigs.rootFolderPath || 'x',
|
|
9
|
+
projectName: rawConfigs.projectName,
|
|
10
|
+
port: process.env.PORT || rawConfigs.port || 3000,
|
|
11
|
+
env: process.env.NODE_ENV,
|
|
12
|
+
...rawConfigs
|
|
13
|
+
};
|
|
16
14
|
};
|
|
15
|
+
get all() {
|
|
16
|
+
return this.config;
|
|
17
|
+
}
|
|
17
18
|
}
|
package/source/project/index.js
CHANGED
|
@@ -33,9 +33,8 @@ const coreLoader = async () => {
|
|
|
33
33
|
tmp: { _: r }
|
|
34
34
|
});
|
|
35
35
|
await configService.load({
|
|
36
|
-
|
|
36
|
+
tmp: r,
|
|
37
37
|
systemService: system,
|
|
38
|
-
envLoadPath: path.join(rootFolderPath, configs.loaders.configs.envLoadPath),
|
|
39
38
|
...(configs.loaders.configs.globalEnvFileName && { globalEnvFileName: configs.loaders.configs.globalEnvFileName })
|
|
40
39
|
});
|
|
41
40
|
await logger.load({
|