@jahands/dagger-helpers 0.3.0 → 0.4.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/dist/env.d.ts +2 -1
- package/dist/env.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/path.d.ts +12 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +33 -0
- package/dist/path.js.map +1 -0
- package/dist/shell.d.ts +15 -0
- package/dist/shell.d.ts.map +1 -1
- package/dist/shell.js +26 -0
- package/dist/shell.js.map +1 -1
- package/package.json +5 -1
package/dist/env.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
1
2
|
import type { Secret } from '@dagger.io/dagger';
|
|
2
3
|
/**
|
|
3
4
|
* Structure stored in AsyncLocalStorage, containing both the fully merged
|
|
@@ -11,7 +12,7 @@ export interface EnvContext {
|
|
|
11
12
|
/**
|
|
12
13
|
* Store for environment variables accessible via AsyncLocalStorage
|
|
13
14
|
*/
|
|
14
|
-
export declare const envStorage:
|
|
15
|
+
export declare const envStorage: AsyncLocalStorage<EnvContext>;
|
|
15
16
|
/**
|
|
16
17
|
* Helper to extract parameter names from a function's source code.
|
|
17
18
|
* Note: This approach using Function.toString() can be fragile and might
|
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAA;CACtD;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,+BAAsC,CAAA;AAE7D;;;;GAIG;AAEH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CA8B1D;AAED;;;GAGG;AAEH,wBAAgB,WAAW,IAAI,eAAe,CA6D7C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { constants } from './constants.js';
|
|
2
2
|
export { ParamsToEnv, envStorage } from './env.js';
|
|
3
3
|
export type { EnvContext } from './env.js';
|
|
4
|
-
export { sh } from './shell.js';
|
|
4
|
+
export { sh, shell } from './shell.js';
|
|
5
|
+
export { getModulePath } from './path.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAGlD,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAGlD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/path.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function getRepoRoot(cwd?: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Get the path to the dagger module.
|
|
4
|
+
*
|
|
5
|
+
* Requires `pnpm-lock.yaml` to exist in the repo root.
|
|
6
|
+
*
|
|
7
|
+
* @param cwd - The current working directory. **Default:** `process.cwd()`
|
|
8
|
+
*
|
|
9
|
+
* @returns The path to the dagger module relative to the repo root
|
|
10
|
+
*/
|
|
11
|
+
export declare function getModulePath(cwd?: string): string;
|
|
12
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAShD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAelD"}
|
package/dist/path.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { up } from 'empathic/find';
|
|
3
|
+
export function getRepoRoot(cwd) {
|
|
4
|
+
cwd = cwd ?? process.cwd();
|
|
5
|
+
const lockfile = up('pnpm-lock.yaml', { cwd });
|
|
6
|
+
if (!lockfile) {
|
|
7
|
+
throw new Error('could not determine repo root path: unable to find pnpm-lock.yaml');
|
|
8
|
+
}
|
|
9
|
+
return path.dirname(lockfile);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get the path to the dagger module.
|
|
13
|
+
*
|
|
14
|
+
* Requires `pnpm-lock.yaml` to exist in the repo root.
|
|
15
|
+
*
|
|
16
|
+
* @param cwd - The current working directory. **Default:** `process.cwd()`
|
|
17
|
+
*
|
|
18
|
+
* @returns The path to the dagger module relative to the repo root
|
|
19
|
+
*/
|
|
20
|
+
export function getModulePath(cwd) {
|
|
21
|
+
cwd = cwd ?? process.cwd();
|
|
22
|
+
const lockfile = up('pnpm-lock.yaml', { cwd });
|
|
23
|
+
if (!lockfile) {
|
|
24
|
+
throw new Error('could not determine repo root path: unable to find pnpm-lock.yaml');
|
|
25
|
+
}
|
|
26
|
+
const repoRoot = path.dirname(lockfile);
|
|
27
|
+
const daggerJson = up('dagger.json', { cwd, stop: repoRoot });
|
|
28
|
+
if (!daggerJson) {
|
|
29
|
+
throw new Error('could not determine dagger.json path: unable to find dagger.json');
|
|
30
|
+
}
|
|
31
|
+
return path.relative(repoRoot, path.dirname(daggerJson));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=path.js.map
|
package/dist/path.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,EAAE,EAAE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
* ```ts
|
|
@@ -8,4 +10,17 @@
|
|
|
8
10
|
* ```
|
|
9
11
|
*/
|
|
10
12
|
export declare function sh(input: string | string[]): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Create a new shell helper with the given shell type
|
|
15
|
+
*
|
|
16
|
+
* @param shellName - The name of the shell to use
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const sh = shell('bash')
|
|
22
|
+
* .withExec(sh('echo hello world!'))
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function shell(shellName: 'sh' | 'bash' | 'zsh'): (input: string | string[]) => string[];
|
|
11
26
|
//# sourceMappingURL=shell.d.ts.map
|
package/dist/shell.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAUrD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,KAAK,WACtC,MAAM,GAAG,MAAM,EAAE,KAAG,MAAM,EAAE,CAW3C"}
|
package/dist/shell.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Run command with bash
|
|
3
3
|
*
|
|
4
|
+
* @deprecated use shell() instead
|
|
5
|
+
*
|
|
4
6
|
* @example
|
|
5
7
|
*
|
|
6
8
|
* ```ts
|
|
@@ -10,9 +12,33 @@
|
|
|
10
12
|
export function sh(input) {
|
|
11
13
|
const inputAr = Array.isArray(input) ? input : [input];
|
|
12
14
|
const trimmedInput = inputAr.map((i) => i
|
|
15
|
+
.trim()
|
|
13
16
|
.split('\n')
|
|
14
17
|
.map((l) => l.trim())
|
|
15
18
|
.join('\n'));
|
|
16
19
|
return ['bash', '-c', trimmedInput].flat();
|
|
17
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a new shell helper with the given shell type
|
|
23
|
+
*
|
|
24
|
+
* @param shellName - The name of the shell to use
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* const sh = shell('bash')
|
|
30
|
+
* .withExec(sh('echo hello world!'))
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function shell(shellName) {
|
|
34
|
+
return (input) => {
|
|
35
|
+
const inputAr = Array.isArray(input) ? input : [input];
|
|
36
|
+
const trimmedInput = inputAr.map((i) => i
|
|
37
|
+
.trim()
|
|
38
|
+
.split('\n')
|
|
39
|
+
.map((l) => l.trim())
|
|
40
|
+
.join('\n'));
|
|
41
|
+
return [shellName, '-c', trimmedInput].flat();
|
|
42
|
+
};
|
|
43
|
+
}
|
|
18
44
|
//# sourceMappingURL=shell.js.map
|
package/dist/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,EAAE,CAAC,KAAwB;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACtD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACtC,CAAC;SACC,IAAI,EAAE;SACN,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,IAAI,CAAC,IAAI,CAAC,CACZ,CAAA;IACD,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,KAAK,CAAC,SAAgC;IACrD,OAAO,CAAC,KAAwB,EAAY,EAAE;QAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QACtD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACtC,CAAC;aACC,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC,CACZ,CAAA;QACD,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,IAAI,EAAE,CAAA;IAC9C,CAAC,CAAA;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jahands/dagger-helpers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "dagger.io helpers for my own projects - not meant for public use",
|
|
6
6
|
"keywords": [
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"devDependencies": {
|
|
37
|
+
"@types/node": "20.8.3",
|
|
37
38
|
"typescript": "5.5.4",
|
|
38
39
|
"vitest": "2.1.1",
|
|
39
40
|
"@repo/tools": "0.8.1",
|
|
@@ -42,6 +43,9 @@
|
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"@dagger.io/dagger": "^0.18.4"
|
|
44
45
|
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"empathic": "1.0.0"
|
|
48
|
+
},
|
|
45
49
|
"scripts": {
|
|
46
50
|
"build": "runx build tsc ./src/index.ts",
|
|
47
51
|
"check:lint": "run-eslint-workers",
|