@gaiaworks/gaia-cli 0.0.8 → 0.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaiaworks/gaia-cli",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "JavaScript launcher for gaia-cli.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -89,11 +89,15 @@ function npmGlobalBinDir() {
89
89
  return process.platform === 'win32' ? prefix : path.join(prefix, 'bin');
90
90
  }
91
91
 
92
- function npmGlobalCommandPath(binDir, platform = process.platform) {
92
+ function npmGlobalCommandPath(binDir, platform = process.platform) {
93
93
  if (!binDir) return null;
94
94
  if (platform === 'win32') return path.win32.join(binDir, 'gaia.cmd');
95
95
  return path.posix.join(binDir, 'gaia');
96
- }
96
+ }
97
+
98
+ function setupCommandPath(packageBinary) {
99
+ return packageBinary;
100
+ }
97
101
 
98
102
  function pathContains(dir) {
99
103
  if (!dir) return false;
@@ -165,9 +169,8 @@ function installWizard(args) {
165
169
  ensureLocalBinary();
166
170
  const npm = npmInvocation(['install', '-g', packageSpec]);
167
171
  run(npm.command, npm.args);
168
- const globalBinDir = npmGlobalBinDir();
169
- const globalCommand = npmGlobalCommandPath(globalBinDir);
170
- const setupCommand = globalCommand && fs.existsSync(globalCommand) ? globalCommand : binaryPath;
172
+ const globalBinDir = npmGlobalBinDir();
173
+ const setupCommand = setupCommandPath(binaryPath);
171
174
  run(setupCommand, ['setup', '--mode', mode], { stdio: 'ignore' });
172
175
  const profilePath = ensurePathConfigured(globalBinDir);
173
176
  const suffix = explicitMode ? `当前模式: ${mode}。` : '';
@@ -200,7 +203,8 @@ module.exports = {
200
203
  npmInvocation,
201
204
  pathContains,
202
205
  pathExportBlock,
203
- shellProfilePath,
206
+ shellProfilePath,
207
+ setupCommandPath,
204
208
  installWizard,
205
209
  parseInstallArgs,
206
210
  };
@@ -20,9 +20,15 @@ function readPackageVersion() {
20
20
  return JSON.parse(content).version;
21
21
  }
22
22
 
23
- function normalizeVersion(version) {
24
- return version.startsWith('v') ? version.slice(1) : version;
25
- }
23
+ function normalizeVersion(version) {
24
+ return version.startsWith('v') ? version.slice(1) : version;
25
+ }
26
+
27
+ function assertInstallableVersion(version) {
28
+ if (normalizeVersion(version) === '0.0.0') {
29
+ throw new Error('Cannot install from a source checkout with placeholder version 0.0.0; use `go run .\\cmd\\gaia <command>` for local development');
30
+ }
31
+ }
26
32
 
27
33
  function platformName(platform = process.platform) {
28
34
  if (platform === 'darwin') return 'darwin';
@@ -129,8 +135,9 @@ function findDownloadedBinary(targetDir, platform = process.platform) {
129
135
  throw new Error(`Downloaded archive does not contain ${expectedName}`);
130
136
  }
131
137
 
132
- function install(options = {}) {
133
- const version = options.version || readPackageVersion();
138
+ function install(options = {}) {
139
+ const version = options.version || readPackageVersion();
140
+ assertInstallableVersion(version);
134
141
  const url = options.url || downloadUrl(version);
135
142
  const archivePath = path.join(os.tmpdir(), archiveName(version));
136
143
  const unpackDir = path.join(os.tmpdir(), `gaia-cli-${process.pid}-${Date.now()}`);
@@ -165,8 +172,9 @@ if (require.main === module) {
165
172
  module.exports = {
166
173
  ALLOWED_DOWNLOAD_HOSTS,
167
174
  archName,
168
- archiveName,
169
- assertAllowedUrl,
175
+ archiveName,
176
+ assertAllowedUrl,
177
+ assertInstallableVersion,
170
178
  binaryName,
171
179
  downloadUrl,
172
180
  findDownloadedBinary,