synsci 1.3.4 → 1.3.5-test.3.1
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/synsci.mjs +16 -6
- package/lib/channel.mjs +12 -0
- package/package.json +3 -2
package/bin/synsci.mjs
CHANGED
|
@@ -23,6 +23,7 @@ import { homedir } from "node:os"
|
|
|
23
23
|
import { join } from "node:path"
|
|
24
24
|
import { createInterface } from "node:readline"
|
|
25
25
|
import { fileURLToPath } from "node:url"
|
|
26
|
+
import { npmDistTag, opensciencePackageSpec } from "../lib/channel.mjs"
|
|
26
27
|
|
|
27
28
|
const SELF_PATH = (() => {
|
|
28
29
|
try {
|
|
@@ -31,6 +32,15 @@ const SELF_PATH = (() => {
|
|
|
31
32
|
return ""
|
|
32
33
|
}
|
|
33
34
|
})()
|
|
35
|
+
const LAUNCHER_VERSION = (() => {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8")).version || "0.0.0"
|
|
38
|
+
} catch {
|
|
39
|
+
return "0.0.0"
|
|
40
|
+
}
|
|
41
|
+
})()
|
|
42
|
+
const OPENSCIENCE_NPM_TAG = npmDistTag(LAUNCHER_VERSION)
|
|
43
|
+
const OPENSCIENCE_NPM_SPEC = opensciencePackageSpec(LAUNCHER_VERSION)
|
|
34
44
|
|
|
35
45
|
const BOLD = "\x1b[1m"
|
|
36
46
|
const DIM = "\x1b[2m"
|
|
@@ -278,13 +288,13 @@ async function main() {
|
|
|
278
288
|
} else {
|
|
279
289
|
const s = spinner("Checking for updates...")
|
|
280
290
|
const current = raw.replace(/[^0-9.]/g, "")
|
|
281
|
-
const latest = runQuiet(
|
|
291
|
+
const latest = runQuiet(`npm view @synsci/openscience@${OPENSCIENCE_NPM_TAG} version`)
|
|
282
292
|
if (!latest || current === latest) {
|
|
283
293
|
s.ok(`openscience ${current} ${DIM}(up to date)${RESET}`)
|
|
284
294
|
} else {
|
|
285
295
|
s.update(`Upgrading ${current} → ${latest}...`)
|
|
286
296
|
try {
|
|
287
|
-
execCli(cliPath, ["upgrade"], { stdio: "pipe" })
|
|
297
|
+
execCli(cliPath, ["upgrade", latest], { stdio: "pipe" })
|
|
288
298
|
s.ok(`Upgraded to ${latest}`)
|
|
289
299
|
} catch {
|
|
290
300
|
s.warn(`Upgrade failed, continuing with ${current}`)
|
|
@@ -295,7 +305,7 @@ async function main() {
|
|
|
295
305
|
const s = spinner("Installing OpenScience...")
|
|
296
306
|
try {
|
|
297
307
|
try {
|
|
298
|
-
execSync(
|
|
308
|
+
execSync(`npm i -g ${OPENSCIENCE_NPM_SPEC}`, { stdio: "pipe" })
|
|
299
309
|
} catch (e) {
|
|
300
310
|
// npm refuses to overwrite a bin file owned by another package
|
|
301
311
|
// (EEXIST). If the conflict is the deprecated @synsci/cli, remove it
|
|
@@ -306,7 +316,7 @@ async function main() {
|
|
|
306
316
|
s.update("Removing the deprecated @synsci/cli so it can't shadow the openscience command...")
|
|
307
317
|
runQuiet("npm rm -g @synsci/cli")
|
|
308
318
|
s.update("Retrying the OpenScience install...")
|
|
309
|
-
execSync(
|
|
319
|
+
execSync(`npm i -g ${OPENSCIENCE_NPM_SPEC}`, { stdio: "pipe" })
|
|
310
320
|
}
|
|
311
321
|
cliPath = resolveCli()
|
|
312
322
|
if (!cliPath) throw new Error("openscience not on PATH after install")
|
|
@@ -316,7 +326,7 @@ async function main() {
|
|
|
316
326
|
// no bash to pipe it into, so don't suggest a fallback that can't run.
|
|
317
327
|
if (process.platform === "win32") {
|
|
318
328
|
s.fail("Install failed")
|
|
319
|
-
console.log(`\n Try manually: ${CYAN}npm i -g
|
|
329
|
+
console.log(`\n Try manually: ${CYAN}npm i -g ${OPENSCIENCE_NPM_SPEC}${RESET}\n`)
|
|
320
330
|
process.exit(1)
|
|
321
331
|
}
|
|
322
332
|
// Global npm installs commonly fail on permissions. Fall back to the
|
|
@@ -330,7 +340,7 @@ async function main() {
|
|
|
330
340
|
s.ok("Installed OpenScience")
|
|
331
341
|
} catch (e2) {
|
|
332
342
|
s.fail(`Install failed${e2 && e2.message ? ": " + e2.message : ""}`)
|
|
333
|
-
console.log(`\n Try manually: ${CYAN}npm i -g
|
|
343
|
+
console.log(`\n Try manually: ${CYAN}npm i -g ${OPENSCIENCE_NPM_SPEC}${RESET}`)
|
|
334
344
|
console.log(` or: ${CYAN}curl -fsSL https://openscience.sh/install | bash${RESET}\n`)
|
|
335
345
|
process.exit(1)
|
|
336
346
|
}
|
package/lib/channel.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const known = new Set(["latest", "ci", "dev", "beta", "test"])
|
|
2
|
+
|
|
3
|
+
export function npmDistTag(version) {
|
|
4
|
+
const value = String(version || "")
|
|
5
|
+
const match = value.match(/^\d+\.\d+\.\d+-([0-9A-Za-z]+)(?:[.-]|$)/)
|
|
6
|
+
const tag = match?.[1] || "latest"
|
|
7
|
+
return known.has(tag) ? tag : "latest"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function opensciencePackageSpec(version) {
|
|
11
|
+
return `@synsci/openscience@${npmDistTag(version)}`
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "synsci",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5-test.3.1",
|
|
4
4
|
"description": "Install wizard for OpenScience, the open-source AI research workspace (optionally with Atlas)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"synsci": "bin/synsci.mjs"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"bin"
|
|
11
|
+
"bin",
|
|
12
|
+
"lib"
|
|
12
13
|
],
|
|
13
14
|
"keywords": [
|
|
14
15
|
"openscience",
|