@positronic/cli 0.0.4 → 0.0.5
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.
|
@@ -48,6 +48,13 @@ function _define_property(obj, key, value) {
|
|
|
48
48
|
}
|
|
49
49
|
return obj;
|
|
50
50
|
}
|
|
51
|
+
function _instanceof(left, right) {
|
|
52
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
53
|
+
return !!right[Symbol.hasInstance](left);
|
|
54
|
+
} else {
|
|
55
|
+
return left instanceof right;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
51
58
|
function _iterable_to_array_limit(arr, i) {
|
|
52
59
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
53
60
|
if (_i == null) return;
|
|
@@ -225,6 +232,7 @@ import { isText } from 'istextorbinary';
|
|
|
225
232
|
import * as http from 'http';
|
|
226
233
|
import * as https from 'https';
|
|
227
234
|
import { URL } from 'url';
|
|
235
|
+
import { execSync } from 'child_process';
|
|
228
236
|
// Singleton API client instance
|
|
229
237
|
export var apiClient = {
|
|
230
238
|
fetch: function(apiPath, options) {
|
|
@@ -244,7 +252,7 @@ export var apiClient = {
|
|
|
244
252
|
};
|
|
245
253
|
export function generateProject(projectName, projectDir) {
|
|
246
254
|
return _async_to_generator(function() {
|
|
247
|
-
var devPath, newProjectTemplatePath, cazOptions, originalNewProjectPkg, copiedNewProjectPkg;
|
|
255
|
+
var devPath, newProjectTemplatePath, cazOptions, tempDir, originalNewProjectPkg, copiedNewProjectPkg, files, tarball, tarballPath;
|
|
248
256
|
return _ts_generator(this, function(_state) {
|
|
249
257
|
switch(_state.label){
|
|
250
258
|
case 0:
|
|
@@ -253,6 +261,7 @@ export function generateProject(projectName, projectDir) {
|
|
|
253
261
|
cazOptions = {
|
|
254
262
|
name: projectName
|
|
255
263
|
};
|
|
264
|
+
tempDir = null;
|
|
256
265
|
_state.label = 1;
|
|
257
266
|
case 1:
|
|
258
267
|
_state.trys.push([
|
|
@@ -281,6 +290,33 @@ export function generateProject(projectName, projectDir) {
|
|
|
281
290
|
install: true,
|
|
282
291
|
pm: 'npm'
|
|
283
292
|
};
|
|
293
|
+
} else if (newProjectTemplatePath.startsWith('@')) {
|
|
294
|
+
// Handle npm package template
|
|
295
|
+
// Create a temp directory for the npm package
|
|
296
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'positronic-npm-template-'));
|
|
297
|
+
// Download the npm package to the temp directory
|
|
298
|
+
try {
|
|
299
|
+
execSync("npm pack ".concat(newProjectTemplatePath, ' --pack-destination="').concat(tempDir, '"'), {
|
|
300
|
+
stdio: 'pipe'
|
|
301
|
+
});
|
|
302
|
+
// Find the packed tarball
|
|
303
|
+
files = fs.readdirSync(tempDir);
|
|
304
|
+
tarball = files.find(function(f) {
|
|
305
|
+
return f.endsWith('.tgz');
|
|
306
|
+
});
|
|
307
|
+
if (!tarball) {
|
|
308
|
+
throw new Error("Failed to find packed tarball for ".concat(newProjectTemplatePath));
|
|
309
|
+
}
|
|
310
|
+
// Extract the tarball
|
|
311
|
+
tarballPath = path.join(tempDir, tarball);
|
|
312
|
+
execSync('tar -xzf "'.concat(tarballPath, '" -C "').concat(tempDir, '"'), {
|
|
313
|
+
stdio: 'pipe'
|
|
314
|
+
});
|
|
315
|
+
// The extracted content is in a 'package' directory
|
|
316
|
+
newProjectTemplatePath = path.join(tempDir, 'package');
|
|
317
|
+
} catch (error) {
|
|
318
|
+
throw new Error("Failed to download template package ".concat(newProjectTemplatePath, ": ").concat(_instanceof(error, Error) ? error.message : String(error)));
|
|
319
|
+
}
|
|
284
320
|
}
|
|
285
321
|
// In test or CI environments, skip interactive prompts and dependency installation
|
|
286
322
|
if (process.env.NODE_ENV === 'test') {
|
|
@@ -305,13 +341,21 @@ export function generateProject(projectName, projectDir) {
|
|
|
305
341
|
];
|
|
306
342
|
case 3:
|
|
307
343
|
// Clean up the temporary copied new project package
|
|
308
|
-
if (devPath) {
|
|
344
|
+
if (devPath && newProjectTemplatePath !== '@positronic/template-new-project') {
|
|
309
345
|
fs.rmSync(newProjectTemplatePath, {
|
|
310
346
|
recursive: true,
|
|
311
347
|
force: true,
|
|
312
348
|
maxRetries: 3
|
|
313
349
|
});
|
|
314
350
|
}
|
|
351
|
+
// Clean up the npm temp directory if it was created
|
|
352
|
+
if (tempDir) {
|
|
353
|
+
fs.rmSync(tempDir, {
|
|
354
|
+
recursive: true,
|
|
355
|
+
force: true,
|
|
356
|
+
maxRetries: 3
|
|
357
|
+
});
|
|
358
|
+
}
|
|
315
359
|
return [
|
|
316
360
|
7
|
|
317
361
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/commands/helpers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/commands/helpers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQtD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;AAGhE,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC;AAGzC,eAAO,MAAM,SAAS;qBACG,MAAM,YAAY,WAAW,KAAG,OAAO,CAAC,QAAQ,CAAC;CASzE,CAAC;AAEF,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBA0G5E;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,EAAE,CAsCxE;AAeD,UAAU,UAAU;IACl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