@titanpl/cli 2.0.3 → 3.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/package.json +6 -6
- package/src/commands/init.js +23 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@titanpl/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "The unified CLI for Titan Planet. Use it to create, manage, build, and deploy high-performance backend projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"titanpl",
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
19
|
"titan": "./index.js",
|
|
20
|
-
"
|
|
20
|
+
"t8n": "./index.js",
|
|
21
21
|
"tit": "./index.js"
|
|
22
22
|
},
|
|
23
23
|
"optionalDependencies": {
|
|
24
|
-
"@titanpl/engine-win32-x64": "2.0.
|
|
25
|
-
"@titanpl/engine-linux-x64": "2.0.
|
|
26
|
-
"@titanpl/engine-darwin-arm64": "2.0.
|
|
24
|
+
"@titanpl/engine-win32-x64": "2.0.4",
|
|
25
|
+
"@titanpl/engine-linux-x64": "2.0.4",
|
|
26
|
+
"@titanpl/engine-darwin-arm64": "2.0.4"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@titanpl/packet": "2.0.
|
|
29
|
+
"@titanpl/packet": "2.0.4",
|
|
30
30
|
"prompts": "^2.4.2",
|
|
31
31
|
"commander": "^11.0.0",
|
|
32
32
|
"chalk": "^4.1.2"
|
package/src/commands/init.js
CHANGED
|
@@ -99,8 +99,27 @@ export async function initCommand(projectName, templateName) {
|
|
|
99
99
|
let templateDir = path.resolve(__dirname, '..', '..', '..', '..', 'templates', selectedTemplate);
|
|
100
100
|
let commonDir = path.resolve(__dirname, '..', '..', '..', '..', 'templates', 'common');
|
|
101
101
|
|
|
102
|
+
const tryPaths = [
|
|
103
|
+
// 1. Monorepo root / titanpl package root
|
|
104
|
+
{ t: path.resolve(__dirname, '..', '..', '..', '..', 'templates', selectedTemplate), c: path.resolve(__dirname, '..', '..', '..', '..', 'templates', 'common') },
|
|
105
|
+
// 2. Published CLI package (global install / npm package)
|
|
106
|
+
{ t: path.resolve(__dirname, '..', '..', 'templates', selectedTemplate), c: path.resolve(__dirname, '..', '..', 'templates', 'common') },
|
|
107
|
+
// 3. Fallback: one dir up? Just in case
|
|
108
|
+
{ t: path.resolve(__dirname, '..', '..', '..', 'templates', selectedTemplate), c: path.resolve(__dirname, '..', '..', '..', 'templates', 'common') }
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
let found = false;
|
|
112
|
+
for (const paths of tryPaths) {
|
|
113
|
+
if (fs.existsSync(paths.t) && fs.existsSync(paths.c)) {
|
|
114
|
+
templateDir = paths.t;
|
|
115
|
+
commonDir = paths.c;
|
|
116
|
+
found = true;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
102
121
|
// Robust monorepo/fallback template search: look upwards from cwd
|
|
103
|
-
if (!
|
|
122
|
+
if (!found) {
|
|
104
123
|
let searchDir = process.cwd();
|
|
105
124
|
while (searchDir !== path.parse(searchDir).root) {
|
|
106
125
|
const potentialTemplateDir = path.join(searchDir, 'templates', selectedTemplate);
|
|
@@ -108,6 +127,7 @@ export async function initCommand(projectName, templateName) {
|
|
|
108
127
|
if (fs.existsSync(potentialTemplateDir) && fs.existsSync(potentialCommonDir)) {
|
|
109
128
|
templateDir = potentialTemplateDir;
|
|
110
129
|
commonDir = potentialCommonDir;
|
|
130
|
+
found = true;
|
|
111
131
|
break;
|
|
112
132
|
}
|
|
113
133
|
const sdkPotentialTemplateDir = path.join(searchDir, 'titanpl-sdk', 'templates', selectedTemplate);
|
|
@@ -115,13 +135,14 @@ export async function initCommand(projectName, templateName) {
|
|
|
115
135
|
if (fs.existsSync(sdkPotentialTemplateDir) && fs.existsSync(sdkPotentialCommonDir)) {
|
|
116
136
|
templateDir = sdkPotentialTemplateDir;
|
|
117
137
|
commonDir = sdkPotentialCommonDir;
|
|
138
|
+
found = true;
|
|
118
139
|
break;
|
|
119
140
|
}
|
|
120
141
|
searchDir = path.dirname(searchDir);
|
|
121
142
|
}
|
|
122
143
|
}
|
|
123
144
|
|
|
124
|
-
if (!
|
|
145
|
+
if (!found) {
|
|
125
146
|
console.log(chalk.red(`✖ Error finding template paths. Are you in a valid Titan monorepo?`));
|
|
126
147
|
process.exit(1);
|
|
127
148
|
}
|