@onslaughtsnail/caelis 0.0.38 → 0.1.0

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
@@ -5,7 +5,7 @@ Install `caelis` from npm.
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm i -g @onslaughtsnail/caelis
8
+ npm i -g @onslaughtsnail/caelis@0.1.0
9
9
  ```
10
10
 
11
11
  Supported platforms: macOS/Linux (`x64`, `arm64`).
@@ -13,7 +13,7 @@ Supported platforms: macOS/Linux (`x64`, `arm64`).
13
13
  or run without global install:
14
14
 
15
15
  ```bash
16
- npx @onslaughtsnail/caelis --help
16
+ npx @onslaughtsnail/caelis@0.1.0 --help
17
17
  ```
18
18
 
19
19
  ## How it works
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onslaughtsnail/caelis",
3
- "version": "0.0.38",
3
+ "version": "0.1.0",
4
4
  "description": "caelis CLI distributed via npm",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -15,8 +15,7 @@
15
15
  "caelis": "bin/caelis.js"
16
16
  },
17
17
  "files": [
18
- "bin",
19
- "scripts",
18
+ "bin/caelis.js",
20
19
  "README.md",
21
20
  "LICENSE"
22
21
  ],
@@ -35,10 +34,10 @@
35
34
  "publish-release": "node ./scripts/publish-release.mjs"
36
35
  },
37
36
  "optionalDependencies": {
38
- "@onslaughtsnail/caelis-darwin-arm64": "0.0.38",
39
- "@onslaughtsnail/caelis-darwin-x64": "0.0.38",
40
- "@onslaughtsnail/caelis-linux-arm64": "0.0.38",
41
- "@onslaughtsnail/caelis-linux-x64": "0.0.38"
37
+ "@onslaughtsnail/caelis-darwin-arm64": "0.1.0",
38
+ "@onslaughtsnail/caelis-darwin-x64": "0.1.0",
39
+ "@onslaughtsnail/caelis-linux-arm64": "0.1.0",
40
+ "@onslaughtsnail/caelis-linux-x64": "0.1.0"
42
41
  },
43
42
  "publishConfig": {
44
43
  "access": "public",
@@ -1,13 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
- const cliPath = path.resolve(__dirname, '..', 'bin', 'caelis.js');
8
-
9
- try {
10
- await fs.chmod(cliPath, 0o755);
11
- } catch {
12
- // best effort
13
- }
@@ -1,79 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import { execFile, spawn } from 'node:child_process';
5
- import { promisify } from 'node:util';
6
-
7
- const execFileAsync = promisify(execFile);
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = path.dirname(__filename);
10
- const packageRoot = path.resolve(__dirname, '..');
11
-
12
- function runCommand(command, args, options) {
13
- return new Promise((resolve, reject) => {
14
- const child = spawn(command, args, {
15
- ...options,
16
- stdio: 'inherit',
17
- });
18
- child.on('error', reject);
19
- child.on('exit', (code) => {
20
- if (code === 0) {
21
- resolve();
22
- return;
23
- }
24
- reject(new Error(`${command} exited with code ${code}`));
25
- });
26
- });
27
- }
28
-
29
- async function readManifest(packageDir) {
30
- const manifestPath = path.join(packageDir, 'package.json');
31
- const raw = await fs.readFile(manifestPath, 'utf8');
32
- return JSON.parse(raw);
33
- }
34
-
35
- async function versionExists(name, version) {
36
- try {
37
- const { stdout } = await execFileAsync(
38
- 'npm',
39
- ['view', `${name}@${version}`, 'version', '--registry=https://registry.npmjs.org'],
40
- { cwd: packageRoot },
41
- );
42
- return stdout.trim() === version;
43
- } catch {
44
- return false;
45
- }
46
- }
47
-
48
- async function publishPackage(packageDir) {
49
- const manifest = await readManifest(packageDir);
50
- if (await versionExists(manifest.name, manifest.version)) {
51
- console.log(`[caelis] skip publish for ${manifest.name}@${manifest.version}; already exists`);
52
- return;
53
- }
54
- console.log(`[caelis] publishing ${manifest.name}@${manifest.version}`);
55
- const args = ['publish', '--access', 'public'];
56
- if (process.env.CAELIS_NPM_PUBLISH_PROVENANCE === 'false') {
57
- args.push('--provenance=false');
58
- }
59
- if (manifest.version.includes('-')) {
60
- args.push('--tag', 'bootstrap');
61
- }
62
- await runCommand('npm', args, { cwd: packageDir });
63
- }
64
-
65
- async function main() {
66
- const inputs = process.argv.slice(2);
67
- if (inputs.length === 0) {
68
- throw new Error('expected at least one package directory');
69
- }
70
- for (const input of inputs) {
71
- const packageDir = path.resolve(input);
72
- await publishPackage(packageDir);
73
- }
74
- }
75
-
76
- main().catch((err) => {
77
- console.error('[caelis] failed to publish packages:', err.message);
78
- process.exit(1);
79
- });
@@ -1,52 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
- const packageRoot = path.resolve(__dirname, '..');
8
-
9
- const platformPackages = [
10
- '@onslaughtsnail/caelis-darwin-arm64',
11
- '@onslaughtsnail/caelis-darwin-x64',
12
- '@onslaughtsnail/caelis-linux-arm64',
13
- '@onslaughtsnail/caelis-linux-x64',
14
- ];
15
-
16
- const manifestPaths = [
17
- path.join(packageRoot, 'package.json'),
18
- path.join(packageRoot, 'packages', 'caelis-darwin-arm64', 'package.json'),
19
- path.join(packageRoot, 'packages', 'caelis-darwin-x64', 'package.json'),
20
- path.join(packageRoot, 'packages', 'caelis-linux-arm64', 'package.json'),
21
- path.join(packageRoot, 'packages', 'caelis-linux-x64', 'package.json'),
22
- ];
23
-
24
- function normalizeVersion(input) {
25
- const version = String(input || '').trim().replace(/^v/, '');
26
- if (!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(version)) {
27
- throw new Error(`invalid version: ${input}`);
28
- }
29
- return version;
30
- }
31
-
32
- async function updateManifest(manifestPath, version) {
33
- const raw = await fs.readFile(manifestPath, 'utf8');
34
- const manifest = JSON.parse(raw);
35
- manifest.version = version;
36
- if (manifest.name === '@onslaughtsnail/caelis') {
37
- manifest.optionalDependencies = Object.fromEntries(
38
- platformPackages.map((packageName) => [packageName, version]),
39
- );
40
- }
41
- await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
42
- }
43
-
44
- async function main() {
45
- const version = normalizeVersion(process.argv[2]);
46
- await Promise.all(manifestPaths.map((manifestPath) => updateManifest(manifestPath, version)));
47
- }
48
-
49
- main().catch((err) => {
50
- console.error('[caelis] failed to update package versions:', err.message);
51
- process.exit(1);
52
- });
@@ -1,78 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import { execFile } from 'node:child_process';
6
- import { promisify } from 'node:util';
7
-
8
- const execFileAsync = promisify(execFile);
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
- const packageRoot = path.resolve(__dirname, '..');
12
-
13
- const targets = [
14
- { os: 'darwin', arch: 'arm64', dir: 'caelis-darwin-arm64' },
15
- { os: 'darwin', arch: 'amd64', dir: 'caelis-darwin-x64' },
16
- { os: 'linux', arch: 'arm64', dir: 'caelis-linux-arm64' },
17
- { os: 'linux', arch: 'amd64', dir: 'caelis-linux-x64' },
18
- ];
19
-
20
- function normalizeVersion(input) {
21
- const version = String(input || '').trim().replace(/^v/, '');
22
- if (!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(version)) {
23
- throw new Error(`invalid version: ${input}`);
24
- }
25
- return version;
26
- }
27
-
28
- async function findFile(rootDir, expectedName) {
29
- const queue = [rootDir];
30
- while (queue.length > 0) {
31
- const current = queue.shift();
32
- const entries = await fs.readdir(current, { withFileTypes: true });
33
- for (const entry of entries) {
34
- const full = path.join(current, entry.name);
35
- if (entry.isDirectory()) {
36
- queue.push(full);
37
- continue;
38
- }
39
- if (entry.isFile() && entry.name === expectedName) {
40
- return full;
41
- }
42
- }
43
- }
44
- return '';
45
- }
46
-
47
- async function stageTarget(version, distDir, target) {
48
- const archiveName = `caelis_${version}_${target.os}_${target.arch}.tar.gz`;
49
- const archivePath = path.join(distDir, archiveName);
50
- const packageDir = path.join(packageRoot, 'packages', target.dir);
51
- const runtimeDir = path.join(packageDir, 'runtime');
52
- const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), `caelis-${target.dir}-`));
53
- try {
54
- await fs.access(archivePath);
55
- await execFileAsync('tar', ['-xzf', archivePath, '-C', tempDir]);
56
- const extractedBin = await findFile(tempDir, 'caelis');
57
- if (!extractedBin) {
58
- throw new Error(`binary not found in ${archiveName}`);
59
- }
60
- await fs.mkdir(runtimeDir, { recursive: true });
61
- const destPath = path.join(runtimeDir, 'caelis');
62
- await fs.copyFile(extractedBin, destPath);
63
- await fs.chmod(destPath, 0o755);
64
- } finally {
65
- await fs.rm(tempDir, { recursive: true, force: true });
66
- }
67
- }
68
-
69
- async function main() {
70
- const version = normalizeVersion(process.argv[2]);
71
- const distDir = path.resolve(process.argv[3] || path.join(packageRoot, '..', 'dist'));
72
- await Promise.all(targets.map((target) => stageTarget(version, distDir, target)));
73
- }
74
-
75
- main().catch((err) => {
76
- console.error('[caelis] failed to stage platform packages:', err.message);
77
- process.exit(1);
78
- });