@dirigiblelabs/dirigible-cli 14.76.0 → 14.82.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 +4 -0
- package/bin/dirigible.js +12 -6
- package/lib/cli-jar.js +101 -0
- package/package.json +6 -3
- package/postinstall.js +11 -0
- package/bin/dirigible-cli.jar +0 -4
package/README.md
CHANGED
|
@@ -22,6 +22,10 @@ workflows.
|
|
|
22
22
|
There are two primary ways to install and use the Dirigible CLI: globally for system-wide access, or locally as a
|
|
23
23
|
development dependency for project-specific use.
|
|
24
24
|
|
|
25
|
+
The CLI JAR is not part of the package: the install downloads the `dirigible-cli` executable JAR of the same version from
|
|
26
|
+
Maven Central and verifies its SHA-256 checksum. When the install skips scripts (`--ignore-scripts`, pnpm) or the
|
|
27
|
+
download fails, the first run of `dirigible` downloads it instead.
|
|
28
|
+
|
|
25
29
|
### 1. Global Installation (Recommended for CLI Tools)
|
|
26
30
|
|
|
27
31
|
Install the CLI globally using `npm` to run the `dirigible` command directly from any directory in your terminal.
|
package/bin/dirigible.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import path from 'node:path';
|
|
5
3
|
import { createRequire } from 'node:module';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { ensureCliJar } from '../lib/cli-jar.js';
|
|
5
|
+
|
|
6
|
+
// downloaded by postinstall.js, or here on the first run when the install skipped it
|
|
7
|
+
let cliJarPath;
|
|
8
|
+
try {
|
|
9
|
+
cliJarPath = await ensureCliJar();
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error(`❌ ${error.message}`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
9
14
|
|
|
10
15
|
// resolve dirigible jar from package @dirigiblelabs/dirigible
|
|
11
16
|
const require = createRequire(import.meta.url);
|
|
@@ -14,7 +19,8 @@ const dirigibleJarPath = require.resolve('@dirigiblelabs/dirigible/data/dirigibl
|
|
|
14
19
|
const userArgs = process.argv.slice(2);
|
|
15
20
|
|
|
16
21
|
// Define commands that require the Dirigible jar
|
|
17
|
-
|
|
22
|
+
// (generate runs the platform's own generator from it, #7793)
|
|
23
|
+
const dirigibleJarCommands = ['start', 'generate'];
|
|
18
24
|
|
|
19
25
|
const userCommand = userArgs[0];
|
|
20
26
|
|
package/lib/cli-jar.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Downloads the CLI jar of this package's version from Maven Central and verifies its SHA-256.
|
|
2
|
+
// The jar is not bundled: since #7708 it carries the intent engine and the templates, and npm
|
|
3
|
+
// refuses a package of its size (#7771).
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import https from 'node:https';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const packageDir = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
11
|
+
const { version } = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8'));
|
|
12
|
+
const dataDir = path.join(packageDir, 'data');
|
|
13
|
+
const versionFile = path.join(dataDir, 'version.txt');
|
|
14
|
+
const url = `https://repo.maven.apache.org/maven2/org/eclipse/dirigible/dirigible-cli/${version}/dirigible-cli-${version}-executable.jar`;
|
|
15
|
+
const MAX_REDIRECTS = 5;
|
|
16
|
+
// some repository hosts and proxies refuse a request without one
|
|
17
|
+
const HEADERS = { 'User-Agent': `dirigible-cli-npm/${version} node/${process.version}` };
|
|
18
|
+
|
|
19
|
+
export const cliJarPath = path.join(dataDir, 'dirigible-cli-executable.jar');
|
|
20
|
+
|
|
21
|
+
function isPresent() {
|
|
22
|
+
return fs.existsSync(cliJarPath) && fs.existsSync(versionFile)
|
|
23
|
+
&& fs.readFileSync(versionFile, 'utf8').trim() === version;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function request(target, redirects = 0) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
https.get(target, { headers: HEADERS }, res => {
|
|
29
|
+
const { statusCode, headers } = res;
|
|
30
|
+
if (statusCode >= 300 && statusCode < 400 && headers.location) {
|
|
31
|
+
res.resume();
|
|
32
|
+
if (redirects >= MAX_REDIRECTS) {
|
|
33
|
+
reject(new Error(`Too many redirects downloading ${target}`));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
resolve(request(new URL(headers.location, target).toString(), redirects + 1));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (statusCode === 404) {
|
|
40
|
+
res.resume();
|
|
41
|
+
// npm publishes at once, Maven Central takes a while to sync a new release
|
|
42
|
+
reject(new Error(`Dirigible CLI v${version} is not on Maven Central yet (${target}). A new release can take up to 30 minutes to appear - retry in a few minutes.`));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (statusCode !== 200) {
|
|
46
|
+
res.resume();
|
|
47
|
+
reject(new Error(`Failed to download ${target}: HTTP ${statusCode}`));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
resolve(res);
|
|
51
|
+
}).on('error', error => reject(new Error(`Failed to download ${target}: ${error.message}`)));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function readText(target) {
|
|
56
|
+
const res = await request(target);
|
|
57
|
+
res.setEncoding('utf8');
|
|
58
|
+
let text = '';
|
|
59
|
+
for await (const chunk of res) {
|
|
60
|
+
text += chunk;
|
|
61
|
+
}
|
|
62
|
+
return text;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function download() {
|
|
66
|
+
const expected = (await readText(`${url}.sha256`)).trim().split(/\s+/)[0].toLowerCase();
|
|
67
|
+
console.error(`⬇️ Downloading Dirigible CLI JAR v${version} from URL: ${url}...`);
|
|
68
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
69
|
+
// Written beside the target and renamed only once verified, so an interrupted or corrupted
|
|
70
|
+
// download never leaves a jar the launcher would run.
|
|
71
|
+
const partFile = `${cliJarPath}.part`;
|
|
72
|
+
const hash = createHash('sha256');
|
|
73
|
+
try {
|
|
74
|
+
const res = await request(url);
|
|
75
|
+
const file = fs.createWriteStream(partFile);
|
|
76
|
+
await new Promise((resolve, reject) => {
|
|
77
|
+
res.on('data', chunk => hash.update(chunk));
|
|
78
|
+
res.on('error', error => reject(new Error(`Download of ${url} interrupted: ${error.message}`)));
|
|
79
|
+
file.on('error', reject);
|
|
80
|
+
file.on('finish', resolve);
|
|
81
|
+
res.pipe(file);
|
|
82
|
+
});
|
|
83
|
+
const actual = hash.digest('hex');
|
|
84
|
+
if (actual !== expected) {
|
|
85
|
+
throw new Error(`Checksum mismatch for ${url}: expected ${expected}, got ${actual}`);
|
|
86
|
+
}
|
|
87
|
+
fs.renameSync(partFile, cliJarPath);
|
|
88
|
+
fs.writeFileSync(versionFile, version, 'utf8');
|
|
89
|
+
console.error(`✅ Download complete: ${cliJarPath}`);
|
|
90
|
+
} finally {
|
|
91
|
+
fs.rmSync(partFile, { force: true });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Downloads the jar unless the one of this package's version is already in place. */
|
|
96
|
+
export async function ensureCliJar() {
|
|
97
|
+
if (!isPresent()) {
|
|
98
|
+
await download();
|
|
99
|
+
}
|
|
100
|
+
return cliJarPath;
|
|
101
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dirigiblelabs/dirigible-cli",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.82.0",
|
|
4
4
|
"description": "Eclipse Dirigible CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"postinstall": "node postinstall.js",
|
|
7
8
|
"dirigible": "node ./bin/dirigible.js"
|
|
8
9
|
},
|
|
9
10
|
"bin": {
|
|
@@ -14,7 +15,9 @@
|
|
|
14
15
|
"url": "git+https://github.com/eclipse-dirigible/dirigible.git"
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
17
|
-
"bin"
|
|
18
|
+
"bin",
|
|
19
|
+
"lib",
|
|
20
|
+
"postinstall.js"
|
|
18
21
|
],
|
|
19
22
|
"keywords": [
|
|
20
23
|
"dirigible-cli",
|
|
@@ -28,6 +31,6 @@
|
|
|
28
31
|
},
|
|
29
32
|
"homepage": "https://github.com/eclipse-dirigible/dirigible#readme",
|
|
30
33
|
"dependencies": {
|
|
31
|
-
"@dirigiblelabs/dirigible": "14.
|
|
34
|
+
"@dirigiblelabs/dirigible": "14.82.0"
|
|
32
35
|
}
|
|
33
36
|
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Fetches the CLI jar at install time. A failure does not fail the install: the launcher
|
|
2
|
+
// downloads the jar on its first run, which also covers installs that skip install scripts
|
|
3
|
+
// (--ignore-scripts, pnpm) and a release Maven Central has not synced yet.
|
|
4
|
+
import { ensureCliJar } from './lib/cli-jar.js';
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
await ensureCliJar();
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.warn(`⚠️ ${error.message}`);
|
|
10
|
+
console.warn('⚠️ The Dirigible CLI JAR will be downloaded on the first run of "dirigible".');
|
|
11
|
+
}
|
package/bin/dirigible-cli.jar
DELETED