@citolab/tspci 2.3.0-alpha.0 → 2.3.0-alpha.2
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 +2 -2
- package/src/cli.js +20 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citolab/tspci",
|
|
3
|
-
"version": "2.3.0-alpha.
|
|
3
|
+
"version": "2.3.0-alpha.2",
|
|
4
4
|
"description": "an opiniated typescript ims-pci builder with tao integration",
|
|
5
5
|
"author": "patrick <patrick.deklein@cito.nl>",
|
|
6
6
|
"repository": "@citolab/tspci",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"help": "tspci --help",
|
|
47
47
|
"init": "tspci init --force --path=../../pcis"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "b1733e486f1b679d0d805bd987c47e19ad83d121"
|
|
50
50
|
}
|
package/src/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { loadConfigFile } from "rollup/dist/loadConfigFile.js";
|
|
3
|
-
import { spawn } from "child_process";
|
|
3
|
+
import { execSync, spawn } from "child_process";
|
|
4
4
|
import { rollup, watch } from "rollup";
|
|
5
5
|
import readline from "readline";
|
|
6
6
|
import chalk from "chalk";
|
|
@@ -241,7 +241,7 @@ const run = async () => {
|
|
|
241
241
|
// if args contains --force then delete the directory if already exists
|
|
242
242
|
if (args.indexOf("--force") >= 0 || args.indexOf("-f") >= 0) {
|
|
243
243
|
if (fs.existsSync(destinationFolder)) {
|
|
244
|
-
console.log(chalk.yellow("Force deleting directory"));
|
|
244
|
+
console.log(chalk.yellow("🗑 Force deleting directory"));
|
|
245
245
|
fs.rmSync(destinationFolder, { recursive: true, force: true });
|
|
246
246
|
}
|
|
247
247
|
}
|
|
@@ -262,7 +262,9 @@ const run = async () => {
|
|
|
262
262
|
pciName = pciName.replace(/[^a-zA-Z0-9]/g, "");
|
|
263
263
|
}
|
|
264
264
|
console.log(chalk.green(`pci: ${pciName}`));
|
|
265
|
-
const description =
|
|
265
|
+
const description =
|
|
266
|
+
(await askOption("What is the description of your pci? (default: pci created with tspci)")) ||
|
|
267
|
+
"pci created with tspci";
|
|
266
268
|
|
|
267
269
|
const options = await selectOptions("Would you like to add other features?", ["tailwind css", "preact"]);
|
|
268
270
|
console.log(chalk.green(`Options: ${options.values.length === 0 ? "none" : options.values}`));
|
|
@@ -275,7 +277,7 @@ const run = async () => {
|
|
|
275
277
|
// copy the content of preset folder to the current folder
|
|
276
278
|
const presetFolder = path.resolve(cliPath, "./../preset/base");
|
|
277
279
|
if (!fs.existsSync(presetFolder)) {
|
|
278
|
-
console.log(chalk.red("Preset folder not found"));
|
|
280
|
+
console.log(chalk.red("❌ Preset folder not found"));
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
console.log(chalk.green("Copying files to PCI project folder"));
|
|
@@ -345,19 +347,9 @@ const run = async () => {
|
|
|
345
347
|
|
|
346
348
|
// run npm instaal in destination folder
|
|
347
349
|
if (args.indexOf("--no-install") === -1) {
|
|
348
|
-
console.log(chalk.green("Installing dependencies"));
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
console.log(chalk.green(data.toString()));
|
|
352
|
-
console.log(chalk.green("Done! You can now start the dev server with npm run dev"));
|
|
353
|
-
|
|
354
|
-
// console.log(chalk.blue("Starting dev server..."));
|
|
355
|
-
// // run npm run dev in destination folder
|
|
356
|
-
// const npm = spawn("npm", ["run", "dev"], { cwd: destinationFolder });
|
|
357
|
-
// npm.stdout.on("data", (data) => {
|
|
358
|
-
// console.log(chalk.blue(data.toString()));
|
|
359
|
-
// });
|
|
360
|
-
});
|
|
350
|
+
console.log(chalk.green("📦 Installing dependencies"));
|
|
351
|
+
execSync("npm install", { cwd: destinationFolder, stdio: [0, 1, 2] });
|
|
352
|
+
console.log(chalk.green("📦 Done! You can now start the dev server with npm run dev"));
|
|
361
353
|
return;
|
|
362
354
|
} else {
|
|
363
355
|
console.log(chalk.yellow("Skipping npm install, run npm install in the project folder to install dependencies"));
|
|
@@ -375,7 +367,10 @@ const run = async () => {
|
|
|
375
367
|
const packageJson = JSON.parse(packageFileContent);
|
|
376
368
|
|
|
377
369
|
const modifyPci = () => {
|
|
378
|
-
const scriptFile = path.join(
|
|
370
|
+
const scriptFile = path.join(
|
|
371
|
+
path.join(path.join(path.join(NODE_MODULES, `@citolab`), `tspci-${targetname}`), "src"),
|
|
372
|
+
`init.mjs`
|
|
373
|
+
);
|
|
379
374
|
let init = false;
|
|
380
375
|
if (fs.existsSync(scriptFile)) {
|
|
381
376
|
// run init() script
|
|
@@ -390,23 +385,15 @@ const run = async () => {
|
|
|
390
385
|
if (!init) {
|
|
391
386
|
console.log(chalk.green(`No init script found for @citolab/tspci-${targetname}`));
|
|
392
387
|
}
|
|
393
|
-
}
|
|
388
|
+
};
|
|
394
389
|
|
|
395
390
|
// check if `@citolab/tspci-${targetname}]}` is already in devDependencies
|
|
396
391
|
if (!packageJson.devDependencies || !packageJson.devDependencies[`@citolab/tspci-${targetname}`]) {
|
|
397
392
|
console.log(chalk.white(`Adding @citolab/tspci-${targetname}`));
|
|
398
393
|
// install @citolab/tspci-${targetname} to devDepencies
|
|
399
|
-
|
|
400
|
-
// wait till npm install is done
|
|
401
|
-
npm.stdout.on("data", (data) => {
|
|
402
|
-
console.log(chalk.green(`successfull installed @citolab/tspci-${targetname}`));
|
|
403
|
-
// run init script if available
|
|
404
|
-
modifyPci();
|
|
405
|
-
});
|
|
406
|
-
} else {
|
|
407
|
-
modifyPci();
|
|
394
|
+
execSync(`npm install @citolab/tspci-${targetname} --save-dev`, { cwd: PACKAGE_ROOT_PATH, stdio: [0, 1, 2] });
|
|
408
395
|
}
|
|
409
|
-
|
|
396
|
+
modifyPci();
|
|
410
397
|
|
|
411
398
|
return;
|
|
412
399
|
}
|
|
@@ -435,7 +422,10 @@ const run = async () => {
|
|
|
435
422
|
console.error("Missing target name. Use tspci --target target");
|
|
436
423
|
}
|
|
437
424
|
const targetname = args[targetIndex + 1];
|
|
438
|
-
const scriptFile = path.join(
|
|
425
|
+
const scriptFile = path.join(
|
|
426
|
+
path.join(path.join(path.join(NODE_MODULES, `@citolab`), `tspci-${targetname}`), "src"),
|
|
427
|
+
`createPackage.mjs`
|
|
428
|
+
);
|
|
439
429
|
import(`file:///${scriptFile}`).then((script) => {
|
|
440
430
|
script.bundle();
|
|
441
431
|
});
|