@chouquette/gleam 1.15.3 → 1.16.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/bin/cli.mjs +3 -3
- package/package.json +7 -7
- package/src/environment/cachedir.mjs +4 -0
- package/src/environment.mjs +2 -0
- package/src/gleam/compiler.mjs +2 -0
- package/src/installer.mjs +12 -6
- package/tsconfig.json +46 -0
package/bin/cli.mjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import * as installer from '#chouquette/installer'
|
|
3
3
|
import * as childProcess from 'node:child_process'
|
|
4
4
|
import * as fs from 'node:fs'
|
|
5
|
-
import * as path from 'node:path'
|
|
6
5
|
|
|
7
6
|
// Replaces __dirname.
|
|
8
7
|
const { cache, dirname } = installer.directories()
|
|
@@ -15,5 +14,6 @@ if (!isExec) await installer.install()
|
|
|
15
14
|
|
|
16
15
|
// Run the compiler.
|
|
17
16
|
const args = process.argv.slice(2)
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
childProcess
|
|
18
|
+
.spawn(data.binPath, args, { stdio: 'inherit' })
|
|
19
|
+
.on('exit', process.exit)
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chouquette/gleam",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"author": "Guillaume Hivert <hivert.is.coming@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"bin":
|
|
8
|
-
"gleam": "bin/cli.mjs"
|
|
9
|
-
},
|
|
7
|
+
"bin": "bin/cli.mjs",
|
|
10
8
|
"repository": {
|
|
11
9
|
"type": "git",
|
|
12
10
|
"url": "git+https://github.com/ghivert/gleam-lang-npm.git"
|
|
@@ -37,10 +35,12 @@
|
|
|
37
35
|
"wrapper"
|
|
38
36
|
],
|
|
39
37
|
"devDependencies": {
|
|
40
|
-
"@trivago/prettier-plugin-sort-imports": "^
|
|
41
|
-
"
|
|
38
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
39
|
+
"@types/node": "^25.6.0",
|
|
40
|
+
"prettier": "^3.8.3",
|
|
41
|
+
"typescript": "^6.0.3"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"tar": "^7.
|
|
44
|
+
"tar": "^7.5.13"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import * as os from 'node:os'
|
|
2
2
|
import * as path from 'node:path'
|
|
3
3
|
|
|
4
|
+
/** @param {string} id */
|
|
4
5
|
function posix(id) {
|
|
5
6
|
const xdgCache = process.env.XDG_CACHE_HOME
|
|
6
7
|
const cacheHome = xdgCache || path.join(os.homedir(), '.cache')
|
|
7
8
|
return path.join(cacheHome, id)
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
/** @param {string} id */
|
|
10
12
|
function darwin(id) {
|
|
11
13
|
return path.join(os.homedir(), 'Library', 'Caches', id)
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
/** @param {string} id */
|
|
14
17
|
function win32(id) {
|
|
15
18
|
const local = process.env.LOCALAPPDATA
|
|
16
19
|
const appData = local || path.join(os.homedir(), 'AppData', 'Local')
|
|
17
20
|
return path.join(appData, id, 'Cache')
|
|
18
21
|
}
|
|
19
22
|
|
|
23
|
+
/** @param {string} id */
|
|
20
24
|
export function cachedir(id) {
|
|
21
25
|
switch (process.platform) {
|
|
22
26
|
case 'darwin':
|
package/src/environment.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import * as path from 'node:path'
|
|
|
3
3
|
|
|
4
4
|
export { cachedir } from './environment/cachedir.mjs'
|
|
5
5
|
|
|
6
|
+
/** @param {string} dirname */
|
|
6
7
|
export async function infos(dirname) {
|
|
7
8
|
const arch = getArch()
|
|
8
9
|
const platform = getPlatform()
|
|
@@ -16,6 +17,7 @@ export function dirname() {
|
|
|
16
17
|
return dirname
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
/** @param {string} dirname */
|
|
19
21
|
async function getVersion(dirname) {
|
|
20
22
|
const pack = path.resolve(dirname, '../package.json')
|
|
21
23
|
const content = await fs.promises.readFile(pack, 'utf-8')
|
package/src/gleam/compiler.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as fs from 'node:fs'
|
|
2
2
|
|
|
3
|
+
/** @param {string} version @param {string} arch @param {string} platform */
|
|
3
4
|
function endpoint(version, arch, platform) {
|
|
4
5
|
const base = 'https://github.com/gleam-lang/gleam/releases/download'
|
|
5
6
|
return `${base}/${version}/gleam-${version}-${arch}-${platform}.tar.gz`
|
|
6
7
|
}
|
|
7
8
|
|
|
9
|
+
/** @param {{ tgzPath: string, version: string, arch: string, platform: string }} options */
|
|
8
10
|
export async function download({ tgzPath, version, arch, platform }) {
|
|
9
11
|
if (fs.existsSync(tgzPath)) return
|
|
10
12
|
const endpt = endpoint(version, arch, platform)
|
package/src/installer.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import * as tar from 'tar'
|
|
|
4
4
|
import * as environment from './environment.mjs'
|
|
5
5
|
import * as gleam from './gleam.mjs'
|
|
6
6
|
|
|
7
|
+
/** @param {{ propagateErrors?: boolean }} [options] */
|
|
7
8
|
export async function install(options) {
|
|
8
9
|
const { dirname, cache } = directories()
|
|
9
10
|
const data = await prepareDownload(dirname, cache)
|
|
@@ -13,12 +14,16 @@ export async function install(options) {
|
|
|
13
14
|
await gleam.compiler.download(data)
|
|
14
15
|
await tar.extract({ file: data.tgzPath, cwd: data.binDir })
|
|
15
16
|
} catch (error) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
if (typeof error === 'object' && error) {
|
|
18
|
+
if ('message' in error && typeof error.message === 'string') {
|
|
19
|
+
const isBadArchive = error.message.includes('TAR_BAD_ARCHIVE')
|
|
20
|
+
const shouldRetry = !(options?.propagateErrors ?? false)
|
|
21
|
+
const archiveExists = fs.existsSync(data.tgzPath)
|
|
22
|
+
if (isBadArchive && shouldRetry && archiveExists) {
|
|
23
|
+
await fs.promises.rm(data.tgzPath)
|
|
24
|
+
return install({ propagateErrors: true })
|
|
25
|
+
}
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
console.error(error)
|
|
24
29
|
console.error(
|
|
@@ -39,6 +44,7 @@ export function directories() {
|
|
|
39
44
|
return { dirname, cache }
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
/** @param {string} dirname @param {string} cache */
|
|
42
48
|
export async function prepareDownload(dirname, cache) {
|
|
43
49
|
const { arch, version, platform } = await environment.infos(dirname)
|
|
44
50
|
if (!arch || !platform) throw new Error('Impossible to detect the env.')
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
// "rootDir": "./src",
|
|
6
|
+
// "outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"types": [],
|
|
14
|
+
// For nodejs:
|
|
15
|
+
// "lib": ["esnext"],
|
|
16
|
+
// "types": ["node"],
|
|
17
|
+
// and npm install -D @types/node
|
|
18
|
+
|
|
19
|
+
// Other Outputs
|
|
20
|
+
"sourceMap": true,
|
|
21
|
+
"declaration": true,
|
|
22
|
+
"declarationMap": true,
|
|
23
|
+
|
|
24
|
+
// Stricter Typechecking Options
|
|
25
|
+
"noUncheckedIndexedAccess": true,
|
|
26
|
+
"exactOptionalPropertyTypes": true,
|
|
27
|
+
|
|
28
|
+
// Style Options
|
|
29
|
+
// "noImplicitReturns": true,
|
|
30
|
+
// "noImplicitOverride": true,
|
|
31
|
+
// "noUnusedLocals": true,
|
|
32
|
+
// "noUnusedParameters": true,
|
|
33
|
+
// "noFallthroughCasesInSwitch": true,
|
|
34
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
35
|
+
|
|
36
|
+
// Recommended Options
|
|
37
|
+
"strict": true,
|
|
38
|
+
"verbatimModuleSyntax": true,
|
|
39
|
+
"erasableSyntaxOnly": true,
|
|
40
|
+
"isolatedModules": true,
|
|
41
|
+
"noUncheckedSideEffectImports": true,
|
|
42
|
+
"moduleDetection": "force",
|
|
43
|
+
"skipLibCheck": true,
|
|
44
|
+
"checkJs": true,
|
|
45
|
+
},
|
|
46
|
+
}
|