@cabloy/cli 3.1.13 → 3.1.14

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
File without changes
package/README.md CHANGED
File without changes
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { glob } from '@cabloy/module-glob';
2
2
  import boxen from 'boxen';
3
3
  import chalk from 'chalk';
4
4
  import { createRequire } from 'node:module';
5
+ import path from 'node:path';
5
6
  import semver from 'semver';
6
7
  import urllib from 'urllib';
7
8
  import NPMConfig from '@npmcli/config';
@@ -9,7 +10,6 @@ import npmDefinitions from '@npmcli/config/lib/definitions/index.js';
9
10
  import DeepEqual from 'deep-equal';
10
11
  import fse from 'fs-extra';
11
12
  import { globby } from 'globby';
12
- import path from 'node:path';
13
13
  import * as ModuleInfo from '@cabloy/module-info';
14
14
  import { ProcessHelper } from '@cabloy/process-helper';
15
15
  import { combineResourceName, catchError, isNil, evaluate } from '@cabloy/utils';
@@ -130,6 +130,12 @@ async function getPackageInfo(packageName) {
130
130
  function patchFlavor(flavor) {
131
131
  return Array.isArray(flavor) ? flavor[flavor.length - 1] : flavor;
132
132
  }
133
+ function parseProjectPath(projectPath) {
134
+ const projectPathDefault = process.cwd();
135
+ if (!projectPath) return projectPathDefault;
136
+ if (path.isAbsolute(projectPath)) return projectPath;
137
+ return path.join(projectPathDefault, projectPath);
138
+ }
133
139
 
134
140
  class LocalCommon {
135
141
  constructor(cli) {
@@ -1603,13 +1609,14 @@ class CabloyCommand extends BaseCommand {
1603
1609
  const parsed = await this[PARSE](this.rawArgv);
1604
1610
  // argv
1605
1611
  const argv = {
1606
- projectPath: process.cwd()
1612
+ projectPath: parseProjectPath(parsed.projectPath)
1607
1613
  };
1608
1614
  // indexBrandName
1609
- const indexBrandName = this.rawArgv.indexOf(this.brandName);
1615
+ const indexBrandName = parsed._.indexOf(this.brandName);
1610
1616
  // cli
1611
- const indexCommand = indexBrandName > -1 ? indexBrandName + 1 : 0;
1612
- Object.assign(argv, this._prepareCliFullName(parsed._[indexCommand]));
1617
+ const commandName = parsed._[indexBrandName + 1];
1618
+ const indexCommand = this.rawArgv.indexOf(commandName);
1619
+ Object.assign(argv, this._prepareCliFullName(commandName));
1613
1620
  // cli meta
1614
1621
  const context = {
1615
1622
  brandName: this.brandName,
@@ -1620,12 +1627,7 @@ class CabloyCommand extends BaseCommand {
1620
1627
  context
1621
1628
  });
1622
1629
  // cli run
1623
- const rawArgv = this.rawArgv.slice();
1624
- if (indexBrandName > -1) {
1625
- rawArgv.splice(0, indexBrandName + 2);
1626
- } else {
1627
- rawArgv.splice(0, 1);
1628
- }
1630
+ const rawArgv = this.rawArgv.slice(indexCommand + 1);
1629
1631
  const command = new CliCommand(rawArgv, {
1630
1632
  meta,
1631
1633
  argv
@@ -1680,4 +1682,4 @@ function metadataCustomSnippet(snippet) {
1680
1682
  return snippet;
1681
1683
  }
1682
1684
 
1683
- export { BeanCli, BeanCliBase, CabloyCommand, CliCommand, LocalConsole, LocalHelper, LocalTemplate, checkForUpdates, collectCommands, commandsConfig, findCommand, getCommandsMeta, getPackageInfo, getRegistry, metadataCustomSnippet, patchFlavor };
1685
+ export { BeanCli, BeanCliBase, CabloyCommand, CliCommand, LocalConsole, LocalHelper, LocalTemplate, checkForUpdates, collectCommands, commandsConfig, findCommand, getCommandsMeta, getPackageInfo, getRegistry, metadataCustomSnippet, parseProjectPath, patchFlavor };
package/dist/utils.d.ts CHANGED
@@ -2,3 +2,4 @@ import type { VonaMetaFlavor } from '@cabloy/module-info';
2
2
  export declare function checkForUpdates(packageName: string): Promise<void>;
3
3
  export declare function getPackageInfo(packageName: string): Promise<any>;
4
4
  export declare function patchFlavor(flavor?: VonaMetaFlavor | VonaMetaFlavor[]): VonaMetaFlavor | undefined;
5
+ export declare function parseProjectPath(projectPath?: string): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cabloy/cli",
3
- "version": "3.1.13",
4
- "gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
3
+ "version": "3.1.14",
4
+ "gitHead": "77e7d321e21482a08f743d441a017f3fb7be43cc",
5
5
  "description": "@cabloy/cli",
6
6
  "keywords": [
7
7
  "cabloy-cli",
@@ -26,9 +26,19 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
+ "scripts": {
30
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
31
+ "tsc:publish": "npm run clean && vona :bin:buildGeneral && tsc",
32
+ "prepublishOnly": "npm run tsc:publish",
33
+ "prepack": "clean-package",
34
+ "postpack": "clean-package restore"
35
+ },
29
36
  "dependencies": {
30
37
  "@babel/parser": "^7.29.2",
38
+ "@cabloy/module-glob": "^5.3.10",
31
39
  "@cabloy/module-info": "^2.0.0",
40
+ "@cabloy/process-helper": "^3.1.5",
41
+ "@cabloy/utils": "^2.1.19",
32
42
  "@cabloy/word-utils": "^2.1.8",
33
43
  "@npmcli/config": "^10.8.1",
34
44
  "@zhennann/common-bin": "^4.0.1",
@@ -45,13 +55,6 @@
45
55
  "istextorbinary": "^3.3.0",
46
56
  "semver": "^7.7.4",
47
57
  "tmp": "^0.2.5",
48
- "urllib": "^4.9.0",
49
- "@cabloy/module-glob": "^5.3.10",
50
- "@cabloy/process-helper": "^3.1.5",
51
- "@cabloy/utils": "^2.1.19"
52
- },
53
- "scripts": {
54
- "clean": "rimraf dist tsconfig.tsbuildinfo",
55
- "tsc:publish": "npm run clean && vona :bin:buildGeneral && tsc"
58
+ "urllib": "^4.9.0"
56
59
  }
57
- }
60
+ }