@citolab/tspci 2.3.0-alpha-5 → 2.3.0-alpha.1
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/preset/base/package.json +2 -3
- package/src/cli.js +31 -22
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.1",
|
|
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": "478292d5b580061e989a3a16a933081d23970962"
|
|
50
50
|
}
|
package/preset/base/package.json
CHANGED
|
@@ -7,12 +7,11 @@
|
|
|
7
7
|
"private": true,
|
|
8
8
|
"dependencies": {},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@citolab/tspci": "
|
|
10
|
+
"@citolab/tspci": "^2.2.0"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"dev": "tspci --dev",
|
|
14
|
-
"prod": "tspci"
|
|
15
|
-
"tspci": "tspci"
|
|
14
|
+
"prod": "tspci"
|
|
16
15
|
},
|
|
17
16
|
"config": {
|
|
18
17
|
"tspci": {
|
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 {
|
|
3
|
+
import { 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("
|
|
244
|
+
console.log(chalk.yellow("Force deleting directory"));
|
|
245
245
|
fs.rmSync(destinationFolder, { recursive: true, force: true });
|
|
246
246
|
}
|
|
247
247
|
}
|
|
@@ -262,9 +262,7 @@ 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 =
|
|
266
|
-
(await askOption("What is the description of your pci? (default: pci created with tspci)")) ||
|
|
267
|
-
"pci created with tspci";
|
|
265
|
+
const description = await askOption("What is the description of your pci? (default: pci created with tspci)") || "pci created with tspci";
|
|
268
266
|
|
|
269
267
|
const options = await selectOptions("Would you like to add other features?", ["tailwind css", "preact"]);
|
|
270
268
|
console.log(chalk.green(`Options: ${options.values.length === 0 ? "none" : options.values}`));
|
|
@@ -277,7 +275,7 @@ const run = async () => {
|
|
|
277
275
|
// copy the content of preset folder to the current folder
|
|
278
276
|
const presetFolder = path.resolve(cliPath, "./../preset/base");
|
|
279
277
|
if (!fs.existsSync(presetFolder)) {
|
|
280
|
-
console.log(chalk.red("
|
|
278
|
+
console.log(chalk.red("Preset folder not found"));
|
|
281
279
|
}
|
|
282
280
|
|
|
283
281
|
console.log(chalk.green("Copying files to PCI project folder"));
|
|
@@ -345,11 +343,21 @@ const run = async () => {
|
|
|
345
343
|
fs.writeFileSync(packageJson, newPackageJsonContent);
|
|
346
344
|
}
|
|
347
345
|
|
|
348
|
-
// run npm
|
|
346
|
+
// run npm instaal in destination folder
|
|
349
347
|
if (args.indexOf("--no-install") === -1) {
|
|
350
|
-
console.log(chalk.green("
|
|
351
|
-
|
|
352
|
-
|
|
348
|
+
console.log(chalk.green("Installing dependencies"));
|
|
349
|
+
const npm = spawn("npm", ["install"], { cwd: destinationFolder, shell: true });
|
|
350
|
+
npm.stdout.on("data", (data) => {
|
|
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
|
+
});
|
|
353
361
|
return;
|
|
354
362
|
} else {
|
|
355
363
|
console.log(chalk.yellow("Skipping npm install, run npm install in the project folder to install dependencies"));
|
|
@@ -362,16 +370,12 @@ const run = async () => {
|
|
|
362
370
|
console.error("Missing target name. Use tspci add --target target");
|
|
363
371
|
return;
|
|
364
372
|
}
|
|
365
|
-
const version = args.indexOf("--next") ? "next" : "latest";
|
|
366
373
|
const targetname = args[targetIndex + 1];
|
|
367
374
|
const packageFileContent = fs.readFileSync(path.join(PACKAGE_ROOT_PATH, "package.json"), "utf8");
|
|
368
375
|
const packageJson = JSON.parse(packageFileContent);
|
|
369
376
|
|
|
370
377
|
const modifyPci = () => {
|
|
371
|
-
const scriptFile = path.join(
|
|
372
|
-
path.join(path.join(path.join(NODE_MODULES, `@citolab`), `tspci-${targetname}`), "src"),
|
|
373
|
-
`init.mjs`
|
|
374
|
-
);
|
|
378
|
+
const scriptFile = path.join(path.join(path.join(path.join(NODE_MODULES, `@citolab`), `tspci-${targetname}`), 'src'), `init.mjs`);
|
|
375
379
|
let init = false;
|
|
376
380
|
if (fs.existsSync(scriptFile)) {
|
|
377
381
|
// run init() script
|
|
@@ -386,15 +390,23 @@ const run = async () => {
|
|
|
386
390
|
if (!init) {
|
|
387
391
|
console.log(chalk.green(`No init script found for @citolab/tspci-${targetname}`));
|
|
388
392
|
}
|
|
389
|
-
}
|
|
393
|
+
}
|
|
390
394
|
|
|
391
395
|
// check if `@citolab/tspci-${targetname}]}` is already in devDependencies
|
|
392
396
|
if (!packageJson.devDependencies || !packageJson.devDependencies[`@citolab/tspci-${targetname}`]) {
|
|
393
397
|
console.log(chalk.white(`Adding @citolab/tspci-${targetname}`));
|
|
394
398
|
// install @citolab/tspci-${targetname} to devDepencies
|
|
395
|
-
|
|
399
|
+
const npm = spawn("npm", ["install", `@citolab/tspci-${targetname}`, "--save-dev"], { cwd: process.cwd(), shell: true });
|
|
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();
|
|
396
408
|
}
|
|
397
|
-
|
|
409
|
+
|
|
398
410
|
|
|
399
411
|
return;
|
|
400
412
|
}
|
|
@@ -423,10 +435,7 @@ const run = async () => {
|
|
|
423
435
|
console.error("Missing target name. Use tspci --target target");
|
|
424
436
|
}
|
|
425
437
|
const targetname = args[targetIndex + 1];
|
|
426
|
-
const scriptFile = path.join(
|
|
427
|
-
path.join(path.join(path.join(NODE_MODULES, `@citolab`), `tspci-${targetname}`), "src"),
|
|
428
|
-
`createPackage.mjs`
|
|
429
|
-
);
|
|
438
|
+
const scriptFile = path.join(path.join(path.join(path.join(NODE_MODULES, `@citolab`), `tspci-${targetname}`), 'src'), `createPackage.mjs`);
|
|
430
439
|
import(`file:///${scriptFile}`).then((script) => {
|
|
431
440
|
script.bundle();
|
|
432
441
|
});
|