@nocobase/cli 2.1.11-test.3 → 2.1.11-test.4

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.
@@ -7,14 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import fs from 'node:fs';
10
- import fsp from 'node:fs/promises';
11
10
  import path from 'node:path';
12
11
  import { fileURLToPath } from 'node:url';
13
- import { resolveCliHomeDir } from './cli-home.js';
14
12
  import { commandOutput, run } from './run-npm.js';
15
13
  const DEFAULT_PACKAGE_NAME = '@nocobase/cli';
16
14
  const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
17
- const INSTALL_METHOD_CACHE_FILE = 'self-install-methods.json';
18
15
  function normalizePath(value) {
19
16
  return path.resolve(value);
20
17
  }
@@ -136,12 +133,6 @@ function isPnpmGlobalPath(packageRoot) {
136
133
  }
137
134
  return segments.slice(globalIndex + 2).includes('node_modules');
138
135
  }
139
- function getInstallMethodCacheFile() {
140
- return path.join(resolveCliHomeDir('global'), INSTALL_METHOD_CACHE_FILE);
141
- }
142
- function getInstallMethodCacheKey(packageRoot) {
143
- return normalizePath(path.join(packageRoot, 'bin', 'run.js'));
144
- }
145
136
  function readCurrentBinPath(currentBinPath) {
146
137
  const candidate = String(currentBinPath ?? process.argv[1] ?? '').trim();
147
138
  if (!candidate) {
@@ -149,32 +140,6 @@ function readCurrentBinPath(currentBinPath) {
149
140
  }
150
141
  return normalizePath(candidate);
151
142
  }
152
- async function readInstallMethodCache() {
153
- try {
154
- const raw = await fsp.readFile(getInstallMethodCacheFile(), 'utf8');
155
- return JSON.parse(raw);
156
- }
157
- catch {
158
- return {};
159
- }
160
- }
161
- async function writeInstallMethodCache(state) {
162
- const filePath = getInstallMethodCacheFile();
163
- await fsp.mkdir(path.dirname(filePath), { recursive: true });
164
- await fsp.writeFile(filePath, JSON.stringify(state, null, 2));
165
- }
166
- async function readCachedInstallMethod(packageRoot) {
167
- const state = await readInstallMethodCache();
168
- return state.entries?.[getInstallMethodCacheKey(packageRoot)];
169
- }
170
- async function writeCachedInstallMethod(packageRoot, entry) {
171
- const state = await readInstallMethodCache();
172
- const entries = {
173
- ...(state.entries ?? {}),
174
- [getInstallMethodCacheKey(packageRoot)]: entry,
175
- };
176
- await writeInstallMethodCache({ entries });
177
- }
178
143
  async function readGlobalPrefix(commandOutputFn) {
179
144
  try {
180
145
  return (await commandOutputFn('npm', ['prefix', '-g'], {
@@ -260,32 +225,17 @@ export function getSelfUpdatePackageSpec(status) {
260
225
  export async function inspectSelfInstall(options = {}) {
261
226
  const packageRoot = options.packageRoot ? normalizePath(options.packageRoot) : PACKAGE_ROOT;
262
227
  const commandOutputFn = options.commandOutputFn ?? commandOutput;
263
- const cachedInstallMethod = await readCachedInstallMethod(packageRoot);
264
228
  const currentBinPath = readCurrentBinPath(options.currentBinPath);
265
- const globalPrefix = cachedInstallMethod?.globalPrefix ?? await readGlobalPrefix(commandOutputFn);
266
- const yarnGlobalDir = cachedInstallMethod?.yarnGlobalDir ?? await readYarnGlobalDir(commandOutputFn);
267
- const yarnGlobalBin = cachedInstallMethod?.yarnGlobalBin ?? await readYarnGlobalBin(commandOutputFn);
268
- const detectedInstallMethod = detectInstallMethodFromSignals({
229
+ const globalPrefix = await readGlobalPrefix(commandOutputFn);
230
+ const yarnGlobalDir = await readYarnGlobalDir(commandOutputFn);
231
+ const yarnGlobalBin = await readYarnGlobalBin(commandOutputFn);
232
+ const installMethod = detectInstallMethodFromSignals({
269
233
  packageRoot,
270
234
  currentBinPath,
271
235
  globalPrefix,
272
236
  yarnGlobalBin,
273
237
  yarnGlobalDir,
274
238
  });
275
- const installMethod = cachedInstallMethod?.installMethod === detectedInstallMethod
276
- ? cachedInstallMethod.installMethod
277
- : detectedInstallMethod;
278
- if (!cachedInstallMethod
279
- || cachedInstallMethod.currentBinPath !== currentBinPath
280
- || cachedInstallMethod.installMethod !== installMethod) {
281
- await writeCachedInstallMethod(packageRoot, {
282
- installMethod,
283
- currentBinPath,
284
- globalPrefix,
285
- yarnGlobalBin,
286
- yarnGlobalDir,
287
- });
288
- }
289
239
  return {
290
240
  packageRoot,
291
241
  installMethod,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.1.11-test.3",
3
+ "version": "2.1.11-test.4",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",