@s2j/global-npm 2.0.2 → 2.0.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.
package/README.md CHANGED
@@ -60,10 +60,12 @@ npm グローバル bin: `%AppData%\npm` (通常 PATH に含まれる)
60
60
  初回 publish 後:
61
61
 
62
62
  ```sh
63
- npm install -g @s2j/global-npm
64
- global-npm install
63
+ npm install -g @s2j/global-npm # CLI 本体の導入(これは一度だけ)
64
+ global-npm install # dependencies 一覧をすべて global install
65
65
  ```
66
66
 
67
+ `global-npm install` は、`@s2j/global-npm` 自身 (自己参照 `^2.0.1`) も含め、`dependencies` のキーを列挙して `npm install -g` します。
68
+
67
69
  ### 開発 — リポジトリ clone
68
70
 
69
71
  ```sh
@@ -80,6 +82,23 @@ global-npm install
80
82
 
81
83
  一覧の変更はリポジトリ更新 → npm publish → `npm update -g @s2j/global-npm` で各環境に反映します。
82
84
 
85
+
86
+ ## 日常の更新サイクル
87
+
88
+ ```mermaid
89
+ flowchart LR
90
+ A["global-npm check"] --> B{"更新あり?"}
91
+ B -->|Yes| C["global-npm update"]
92
+ C --> D["global-npm install"]
93
+ B -->|No| E["終了"]
94
+ ```
95
+
96
+ * **check** … 読み取り専用。何が新しいか (公開日時付き) を見るだけ
97
+ * **update** … `@s2j/global-npm` 同梱の `package.json` の `dependencies` バージョン範囲を更新
98
+ * **install** … その一覧に従って実際にグローバルパッケージを入れ直す/更新する
99
+
100
+ `global-npm install` は、`@s2j/global-npm` 自身 (自己参照 `^2.0.1`) も含め、`dependencies` のキーを列挙して `npm install -g` します。
101
+
83
102
  ## 開発用 scripts
84
103
 
85
104
  CLI 実装のデバッグ用に、リポジトリ root から次の npm scripts も使えます。
@@ -13,7 +13,7 @@ function usage() {
13
13
 
14
14
  check Check for available updates (ncu -g)
15
15
  update Update version ranges in package.json (ncu -g -u)
16
- install Install dependencies globally (npm install -g <each>)`);
16
+ install Install dependencies globally (npm install -g <name>@<range>…)`);
17
17
  process.exit(1);
18
18
  }
19
19
 
@@ -31,6 +31,24 @@ function run(command, args) {
31
31
  process.exit(result.status ?? 1);
32
32
  }
33
33
 
34
+ function toGlobalInstallSpec(name, versionRange) {
35
+ if (typeof versionRange === 'string' && versionRange.trim() !== '') {
36
+ return `${name}@${versionRange}`;
37
+ }
38
+
39
+ return name;
40
+ }
41
+
42
+ function readDependencies() {
43
+ try {
44
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
45
+ return pkg.dependencies ?? {};
46
+ } catch (err) {
47
+ console.error(`Failed to read ${pkgPath}: ${err.message}`);
48
+ process.exit(1);
49
+ }
50
+ }
51
+
34
52
  const subcommand = process.argv[2];
35
53
 
36
54
  switch (subcommand) {
@@ -43,24 +61,17 @@ switch (subcommand) {
43
61
  break;
44
62
 
45
63
  case 'install': {
46
- let dependencies;
47
-
48
- try {
49
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
50
- dependencies = pkg.dependencies ?? {};
51
- } catch (err) {
52
- console.error(`Failed to read ${pkgPath}: ${err.message}`);
53
- process.exit(1);
54
- }
55
-
56
- const names = Object.keys(dependencies);
64
+ const dependencies = readDependencies();
65
+ const specs = Object.entries(dependencies).map(([name, range]) =>
66
+ toGlobalInstallSpec(name, range),
67
+ );
57
68
 
58
- if (names.length === 0) {
69
+ if (specs.length === 0) {
59
70
  console.error('No dependencies to install.');
60
71
  process.exit(1);
61
72
  }
62
73
 
63
- run('npm', ['install', '-g', ...names]);
74
+ run('npm', ['install', '-g', ...specs]);
64
75
  break;
65
76
  }
66
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s2j/global-npm",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Manage globally installed npm packages via package.json with ncu.",
5
5
  "author": "Koutarou ISHIKAWA <stein2nd@gmail.com>",
6
6
  "type": "commonjs",
@@ -37,11 +37,11 @@
37
37
  "test": "node --test test/spec-compliance.test.cjs",
38
38
  "lint": "eslint .",
39
39
  "lint:fix": "eslint . --fix",
40
- "lint:docs": "s2j-docs-linter --profile base ./README.md ./docsMod/**/*.md ./.vscode/**/*.md",
40
+ "lint:docs": "s2j-docs-linter --profile base ./README.md ./docs/**/*.md ./docsMod/status.md ./docsMod/modification.md ./.vscode/**/*.md",
41
41
  "format": "prettier --write \"**/*.{cjs,js,mjs,json}\"",
42
42
  "format:check": "prettier --check \"**/*.{cjs,js,mjs,json}\"",
43
- "pack": "npm pack --pack-destination artifacts",
44
- "pack:dry-run": "npm pack --dry-run --pack-destination artifacts",
43
+ "pack": "mkdir -p artifacts && npm pack --pack-destination artifacts",
44
+ "pack:dry-run": "mkdir -p artifacts && npm pack --dry-run --pack-destination artifacts",
45
45
  "ncu:check": "ncu -g --format time --packageFile package.json",
46
46
  "ncu:update": "ncu -g --format time -u --packageFile package.json"
47
47
  },
@@ -55,7 +55,7 @@
55
55
  "typescript": "^5.9.3"
56
56
  },
57
57
  "dependencies": {
58
- "@s2j/global-npm": "^2.0.1",
58
+ "@s2j/global-npm": "^2.0.2",
59
59
  "corepack": "^0.35.0",
60
60
  "editorconfig-cli": "^1.0.0",
61
61
  "envinfo": "^7.21.0",