create-kosh-erp 0.1.2 → 0.1.3

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 (3) hide show
  1. package/README.md +5 -3
  2. package/index.js +21 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3,12 +3,14 @@
3
3
  Install [Kosh](https://www.npmjs.com/package/kosh-erp) and set it up in one command:
4
4
 
5
5
  ```sh
6
- npm create kosh-erp@latest my-erp
6
+ npm create kosh-erp@latest my-erp # the project my-erp
7
+ npm create kosh-erp@latest # asks for the project name first
7
8
  ```
8
9
 
9
- It creates the folder, installs `kosh-erp` (Shutro comes with it), then asks for:
10
+ It creates the project folder, installs `kosh-erp` (Shutro comes with it), then asks for:
10
11
 
11
- - the PostgreSQL database (your server, or one started in Docker for you; a missing database is created)
12
+ - the PostgreSQL database: your server (username, password, port, host, database name; a missing database is
13
+ created), or one started in Docker for you
12
14
  - the company (name, currency, language, time zone)
13
15
  - the administrator (login, name, email, password) and its authenticator app
14
16
  - the apps (roles and approvals, reports and documents, chatter and attachments)
package/index.js CHANGED
@@ -63,13 +63,30 @@ const add = (cwd, what) =>
63
63
  const installAll = (cwd) =>
64
64
  run(pm, pm === 'npm' ? ['install', '--no-audit', '--no-fund'] : ['install'], cwd);
65
65
 
66
+ /** A project name: a folder name and a valid package name (lower-case letters, digits, - and _). */
67
+ const validName = (name) => /^[a-z0-9][a-z0-9._-]{0,213}$/.test(name);
68
+
69
+ /** The project name: `npm create kosh-erp my-erp`, else asked (Enter: my-erp). */
66
70
  async function folder() {
67
- if (positional !== undefined) return positional;
71
+ if (positional !== undefined) {
72
+ if (!validName(basename(resolve(positional)))) {
73
+ process.stderr.write(
74
+ `"${positional}" is not a project name: lower-case letters, digits, - and _ (e.g. my-erp).\n`,
75
+ );
76
+ process.exit(2);
77
+ }
78
+ return positional;
79
+ }
68
80
  if (!process.stdin.isTTY) return 'my-erp';
69
81
  const rl = createInterface({ input: process.stdin, output: process.stdout });
70
- const answer = (await rl.question('Project folder [my-erp]: ')).trim();
71
- rl.close();
72
- return answer === '' ? 'my-erp' : answer;
82
+ for (;;) {
83
+ const answer = (await rl.question('Project name [my-erp]: ')).trim() || 'my-erp';
84
+ if (validName(answer)) {
85
+ rl.close();
86
+ return answer;
87
+ }
88
+ process.stdout.write(' Lower-case letters, digits, - and _ (e.g. my-erp, padma-traders).\n');
89
+ }
73
90
  }
74
91
 
75
92
  const target = resolve(await folder());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kosh-erp",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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",