@travetto/scaffold 4.0.4 → 4.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 ArcSine Technologies
3
+ Copyright (c) 2023 ArcSine Technologies
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,18 +1,45 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- (async function () {
4
- const args = [...process.argv.slice(0, 2), 'scaffold', ...process.argv.slice(2)];
3
+ async function getScaffoldCwd() {
4
+ let cwd = process.cwd();
5
5
  if (process.env.npm_lifecycle_script === 'trv-scaffold') { // Is npx run
6
- const path = await import('path');
7
- const parts = process.env.PATH.split(path.delimiter);
6
+ const { delimiter } = await import('node:path');
7
+ const parts = process.env.PATH.split(delimiter);
8
8
  const loc = parts.find(p => p.includes('npx') && p.includes('.bin'));
9
9
  if (loc) {
10
- const final = loc.split('/node_modules')[0];
11
- args.push('-c', process.cwd());
12
- process.chdir(final);
10
+ cwd = loc.split('/node_modules')[0];
13
11
  }
14
12
  }
15
- process.argv = args;
16
- process.env.TRV_QUIET = 1;
17
- await import('@travetto/cli/bin/trv.js');
13
+ return cwd;
14
+ }
15
+
16
+ async function getVersion(cwd) {
17
+ const fs = await import('node:fs/promises');
18
+ const pkg = JSON.parse(await fs.readFile(`${cwd}/package.json`, 'utf8'));
19
+ const version = pkg.version.replace(/(\d+[.]\d+)[.]\d+/, (_, v) => `${v}.0`).replace(/-([a-z]+)[.]\d+$/, (_, v) => `${v}.0`);
20
+ return version;
21
+ }
22
+
23
+ (async function () {
24
+ const scaffoldCwd = await getScaffoldCwd();
25
+ const version = await getVersion(scaffoldCwd);
26
+
27
+ const { spawn } = await import('node:child_process');
28
+ spawn('npx', [
29
+ `--package=@travetto/compiler@~${version}`,
30
+ '--',
31
+ 'trvc', 'exec',
32
+ '@travetto/cli/support/entry.trv.js',
33
+ 'scaffold',
34
+ '-c', process.cwd(),
35
+ ...process.argv.slice(2)
36
+ ], {
37
+ stdio: 'inherit',
38
+ cwd: scaffoldCwd,
39
+ env: {
40
+ ...process.env,
41
+ TRV_QUIET: 1,
42
+ NPM_CONFIG_YES: 'true'
43
+ }
44
+ });
18
45
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/scaffold",
3
- "version": "4.0.4",
3
+ "version": "4.0.5",
4
4
  "description": "App Scaffold for the Travetto framework",
5
5
  "keywords": [
6
6
  "generator",
@@ -27,9 +27,8 @@
27
27
  "trv-scaffold": "./bin/trv-scaffold.js"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/base": "^4.0.1",
31
- "@travetto/cli": "^4.0.3",
32
- "@travetto/compiler": "^4.0.3",
30
+ "@travetto/base": "^4.0.2",
31
+ "@travetto/cli": "^4.0.4",
33
32
  "enquirer": "^2.4.1",
34
33
  "mustache": "^4.2.0"
35
34
  },