climaybe 2.2.3 → 2.2.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.
- package/bin/cli.js +8 -11
- package/bin/version.txt +1 -1
- package/package.json +1 -1
- package/src/lib/cli-version.js +20 -0
package/bin/cli.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { readFileSync, existsSync } from 'node:fs';
|
|
4
3
|
import { createRequire } from 'node:module';
|
|
5
4
|
import { dirname, join } from 'node:path';
|
|
6
5
|
import { fileURLToPath } from 'node:url';
|
|
7
6
|
import { run } from '../src/index.js';
|
|
7
|
+
import { resolveCliVersion } from '../src/lib/cli-version.js';
|
|
8
8
|
import { maybeOfferCliUpdate } from '../src/lib/update-notifier.js';
|
|
9
9
|
|
|
10
10
|
const require = createRequire(import.meta.url);
|
|
11
11
|
const binDir = dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
const packageDir = join(binDir, '..');
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
version
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const packageName = require(join(packageDir, 'package.json')).name || 'climaybe';
|
|
14
|
+
const pkg = require(join(packageDir, 'package.json'));
|
|
15
|
+
const version = resolveCliVersion({
|
|
16
|
+
packageDir,
|
|
17
|
+
binDir,
|
|
18
|
+
packageVersion: pkg.version,
|
|
19
|
+
});
|
|
20
|
+
const packageName = pkg.name || 'climaybe';
|
|
24
21
|
await maybeOfferCliUpdate({ packageName, currentVersion: version, packageDir });
|
|
25
22
|
run(process.argv, version, packageDir);
|
package/bin/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.2.
|
|
1
|
+
2.2.4
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the version shown by the CLI.
|
|
6
|
+
* - In dev checkouts (e.g. npm link), prefer package.json.
|
|
7
|
+
* - In packaged installs, prefer bin/version.txt and fallback to package.json.
|
|
8
|
+
*/
|
|
9
|
+
export function resolveCliVersion({ packageDir, binDir, packageVersion }) {
|
|
10
|
+
const devCheckout = existsSync(join(packageDir, '.git'));
|
|
11
|
+
if (devCheckout) return packageVersion;
|
|
12
|
+
|
|
13
|
+
const versionFile = join(binDir, 'version.txt');
|
|
14
|
+
if (existsSync(versionFile)) {
|
|
15
|
+
const baked = readFileSync(versionFile, 'utf8').trim();
|
|
16
|
+
if (baked) return baked;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return packageVersion;
|
|
20
|
+
}
|