vovk 1.0.0 → 1.0.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/README.md CHANGED
@@ -33,7 +33,8 @@ Misc
33
33
  - Update personal README
34
34
 
35
35
  General:
36
- - Merge and remove v1 branches
36
+ - Remove v1 branches
37
+ - Update deps of all projects to v1
37
38
  */
38
39
 
39
40
  -->
package/cli/getVars.js CHANGED
@@ -4,7 +4,7 @@ const path = require('path');
4
4
 
5
5
  /** @type {import('../src').VovkEnv} */
6
6
  let vars;
7
- /** @type {(rcPath: string, options?: { VOVK_CLIENT_OUT?: string; PORT?: string; }) => import('../src').VovkEnv} */
7
+ /** @type {(configPath: string, options?: { VOVK_CLIENT_OUT?: string; PORT?: string; }) => import('../src').VovkEnv} */
8
8
  function getVars(configPath, options = {}) {
9
9
  if (vars) return vars;
10
10
  /** @type {Required<import('../src').VovkConfig>} */
@@ -7,25 +7,35 @@ function toCamelCase(str) {
7
7
 
8
8
  /** @typedef {{ config?: string; project?: string; clientOut?: string; noNextDev?: true }} Flags */
9
9
  /** @typedef {'dev' | 'build' | 'generate' | 'help'} Command */
10
+ /** @type {() => { command: Command | null; flags: Flags; restArgs: string }} */
10
11
  function parseCommandLineArgs() {
11
12
  const args = process.argv.slice(2); // Slice off node and script path
12
- let command = /** @type {Command} */ null;
13
+ const unparsedIndex = args.indexOf('--');
14
+ const commandArgs = unparsedIndex !== -1 ? args.slice(0, unparsedIndex) : args;
15
+ const restArgs = unparsedIndex !== -1 ? args.slice(unparsedIndex + 1).join(' ') : '';
16
+
17
+ let command = /** @type {Command | null} */ (null);
13
18
  /** @type {Flags} */
14
19
  const flags = {};
15
- /** @type {string[]} */
16
- const unparsedArgs = [];
17
-
18
- let isUnparsed = false;
19
- for (const arg of args) {
20
- if (arg === '--') {
21
- isUnparsed = true;
22
- continue;
23
- }
24
20
 
25
- if (isUnparsed) {
26
- unparsedArgs.push(arg);
27
- } else if (arg.startsWith('--')) {
28
- const [key, value = true] = arg.slice(2).split('=');
21
+ for (let i = 0; i < commandArgs.length; i++) {
22
+ const arg = commandArgs[i];
23
+ if (arg.startsWith('--')) {
24
+ /** @type {string} */
25
+ let key = arg.slice(2);
26
+ /** @type {string | true} */
27
+ let value; // Assume flag is boolean unless a value is found
28
+
29
+ if (arg.includes('=')) {
30
+ [key, value] = arg.slice(2).split('=');
31
+ } else if (i + 1 < commandArgs.length && !commandArgs[i + 1].startsWith('--')) {
32
+ // Look ahead to next arg if it exists and is not a flag
33
+ value = commandArgs[i + 1];
34
+ i++; // Skip next arg since it's consumed as a value here
35
+ } else {
36
+ value = true;
37
+ }
38
+
29
39
  const camelKey = /** @type {keyof Flags} */ (toCamelCase(key));
30
40
  // @ts-expect-error Type 'string | true | undefined' is not assignable to type 'undefined'. Why?
31
41
  flags[camelKey] = /** @type {Flags[keyof Flags]} */ (value);
@@ -34,7 +44,7 @@ function parseCommandLineArgs() {
34
44
  }
35
45
  }
36
46
 
37
- const restArgs = unparsedArgs.join(' ');
47
+ if (!command) throw new Error('No command provided');
38
48
 
39
49
  return { command, flags, restArgs };
40
50
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Structural add-on for Next.js",
5
5
  "bin": "./cli/index.js",
6
6
  "scripts": {
7
7
  "postinstall": "node ./cli/postinstall.js",
8
8
  "upgrade": "npx npm-check-updates -u && npm i",
9
- "test": "npm run lint-nofix && tsc --noemit && tsc --project tsconfig.cli.json --noemit && npm run unit",
9
+ "test": "npm --prefix test run generate && npm run lint-nofix && tsc --noemit && tsc --project tsconfig.cli.json --noemit && npm run unit",
10
10
  "unit": "PORT=3210 concurrently \"sleep 20 && npm run test:unit\" \"npm run serve:unit\" --kill-others --success first",
11
11
  "unit:watch": "PORT=3210 concurrently \"sleep 20 && npm run test:unit:watch\" \"npm run serve:unit\" --kill-others --success first",
12
12
  "test:unit": "jest",