create-kosh-erp 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/index.js +8 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -18,15 +18,16 @@ import { createInterface } from 'node:readline/promises';
18
18
 
19
19
  const own = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
20
20
  /** What to install: kosh-erp of the same minor version (KOSH_ERP_SPEC overrides it, e.g. a local tarball). */
21
- const spec = process.env.KOSH_ERP_SPEC ?? `kosh-erp@^${own.version}`;
21
+ const [major, minor] = own.version.split('.');
22
+ const spec = process.env.KOSH_ERP_SPEC ?? `kosh-erp@^${major}.${minor}.0`;
22
23
 
23
- const argv = process.argv.slice(2);
24
- const dashes = argv.indexOf('--');
25
- const ours = dashes === -1 ? argv : argv.slice(0, dashes);
26
- const forInit = dashes === -1 ? argv.filter((a) => a.startsWith('-')) : argv.slice(dashes + 1);
27
- const positional = ours.find((a) => !a.startsWith('-'));
24
+ // `npm create kosh-erp my-erp -- --yes …` reaches us without the `--` (npm consumes it); `npx create-kosh-erp`
25
+ // keeps it. Either way: an optional folder first, everything else is for kosh init.
26
+ const argv = process.argv.slice(2).filter((a, i, all) => !(a === '--' && all.indexOf('--') === i));
27
+ const positional = argv[0] !== undefined && !argv[0].startsWith('-') ? argv[0] : undefined;
28
+ const forInit = positional === undefined ? argv : argv.slice(1);
28
29
 
29
- if (ours.includes('--help') || ours.includes('-h')) {
30
+ if (forInit.length === argv.length && (argv[0] === '--help' || argv[0] === '-h')) {
30
31
  process.stdout.write(`Usage: npm create kosh-erp@latest [folder] [-- kosh init options]
31
32
 
32
33
  Creates a Kosh installation in [folder]: installs kosh-erp, then asks for the database, the company, the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kosh-erp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "npm create kosh-erp: install Kosh and set it up in one command (database, company, administrator, apps, port)",
5
5
  "keywords": [
6
6
  "kosh",