@eighty4/c2 0.0.2-12 → 0.0.2-25
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 +1 -1
- package/lib/attachments.spec.ts +2 -2
- package/lib/attachments.ts +1 -1
- package/lib/build.spec.ts +2 -2
- package/lib/build.ts +3 -3
- package/lib/c2.api.ts +1 -1
- package/lib/c2.bin.ts +3 -3
- package/lib/cli.spec.ts +10 -7
- package/lib/cli.ts +6 -1
- package/lib/expression.spec.ts +2 -2
- package/lib/expression.ts +1 -1
- package/lib_js/attachments.js +1 -1
- package/lib_js/build.js +3 -3
- package/lib_js/c2.api.js +1 -1
- package/lib_js/c2.bin.js +3 -3
- package/lib_js/cli.js +6 -1
- package/lib_js/expression.js +1 -1
- package/lib_types/c2.api.d.ts +1 -1
- package/lib_types/c2.api.d.ts.map +1 -1
- package/lib_types/cli.d.ts.map +1 -1
- package/package.json +1 -5
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ const userData: string = await buildUserData('./cloud_init_dir')
|
|
|
30
30
|
|
|
31
31
|
## Cloud Config data dir
|
|
32
32
|
|
|
33
|
-
Multiple user data are ordered by filenames and `01_` numbered prefixes help
|
|
33
|
+
Multiple user data are ordered by filenames and `01_` numbered prefixes help declare execution order.
|
|
34
34
|
|
|
35
35
|
```
|
|
36
36
|
ls ./cloud_init_dir
|
package/lib/attachments.spec.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterEach, beforeEach, expect, test } from 'bun:test'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
|
-
import { collectAttachments } from '
|
|
4
|
-
import { makeFile, makeTempDir, removeDir } from '
|
|
3
|
+
import { collectAttachments } from './attachments.ts'
|
|
4
|
+
import { makeFile, makeTempDir, removeDir } from './fs.testing.ts'
|
|
5
5
|
|
|
6
6
|
let tmpDir: string
|
|
7
7
|
|
package/lib/attachments.ts
CHANGED
package/lib/build.spec.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { afterEach, beforeEach, expect, test } from 'bun:test'
|
|
2
|
-
import { buildUserData } from '
|
|
3
|
-
import { makeFile, makeTempDir, removeDir } from '
|
|
2
|
+
import { buildUserData } from './build.ts'
|
|
3
|
+
import { makeFile, makeTempDir, removeDir } from './fs.testing.ts'
|
|
4
4
|
|
|
5
5
|
let tmpDir: string
|
|
6
6
|
|
package/lib/build.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Attachment, collectAttachments } from '
|
|
2
|
-
import { evalTemplateExpressions } from '
|
|
3
|
-
import { readToString } from '
|
|
1
|
+
import { type Attachment, collectAttachments } from './attachments.ts'
|
|
2
|
+
import { evalTemplateExpressions } from './expression.ts'
|
|
3
|
+
import { readToString } from './fs.ts'
|
|
4
4
|
|
|
5
5
|
export type BuildUserDataOpts = {
|
|
6
6
|
attachmentBoundary?: string
|
package/lib/c2.api.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type BuildUserDataOpts, buildUserData } from '
|
|
1
|
+
export { type BuildUserDataOpts, buildUserData } from './build.ts'
|
package/lib/c2.bin.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { buildUserData } from '
|
|
4
|
-
import { parseArgs, type ParsedArgs } from '
|
|
5
|
-
import { doesDirExist } from '
|
|
3
|
+
import { buildUserData } from './build.ts'
|
|
4
|
+
import { parseArgs, type ParsedArgs } from './cli.ts'
|
|
5
|
+
import { doesDirExist } from './fs.ts'
|
|
6
6
|
|
|
7
7
|
let args: ParsedArgs | undefined
|
|
8
8
|
try {
|
package/lib/cli.spec.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { expect, test } from 'bun:test'
|
|
2
|
-
import { parseArgs } from '
|
|
2
|
+
import { parseArgs } from './cli.ts'
|
|
3
3
|
|
|
4
4
|
test('parseArgs', () => {
|
|
5
5
|
expect(
|
|
6
6
|
parseArgs([
|
|
7
7
|
'/Users/who/.bun/bin/bun',
|
|
8
|
-
'/Users/who/user-data/c2.ts',
|
|
8
|
+
'/Users/who/user-data/c2.bin.ts',
|
|
9
9
|
'user_data_dir',
|
|
10
10
|
]),
|
|
11
11
|
).toStrictEqual({
|
|
@@ -16,7 +16,10 @@ test('parseArgs', () => {
|
|
|
16
16
|
|
|
17
17
|
test('parseArgs errors without USER_DATA_DIR', () => {
|
|
18
18
|
expect(() =>
|
|
19
|
-
parseArgs([
|
|
19
|
+
parseArgs([
|
|
20
|
+
'/Users/who/.bun/bin/bun',
|
|
21
|
+
'/Users/who/user-data/c2.bin.ts',
|
|
22
|
+
]),
|
|
20
23
|
).toThrow()
|
|
21
24
|
})
|
|
22
25
|
|
|
@@ -24,7 +27,7 @@ test('parseArgs errors with extra USER_DATA_DIR', () => {
|
|
|
24
27
|
expect(() =>
|
|
25
28
|
parseArgs([
|
|
26
29
|
'/Users/who/.bun/bin/bun',
|
|
27
|
-
'/Users/who/user-data/c2.ts',
|
|
30
|
+
'/Users/who/user-data/c2.bin.ts',
|
|
28
31
|
'user_data_dir',
|
|
29
32
|
'some_other_arg',
|
|
30
33
|
]),
|
|
@@ -35,7 +38,7 @@ test('parseArgs with --base64', () => {
|
|
|
35
38
|
expect(
|
|
36
39
|
parseArgs([
|
|
37
40
|
'/Users/who/.bun/bin/bun',
|
|
38
|
-
'/Users/who/user-data/c2.ts',
|
|
41
|
+
'/Users/who/user-data/c2.bin.ts',
|
|
39
42
|
'--base64',
|
|
40
43
|
'user_data_dir',
|
|
41
44
|
]),
|
|
@@ -49,7 +52,7 @@ test('parseArgs with --http PORT', () => {
|
|
|
49
52
|
expect(
|
|
50
53
|
parseArgs([
|
|
51
54
|
'/Users/who/.bun/bin/bun',
|
|
52
|
-
'/Users/who/user-data/c2.ts',
|
|
55
|
+
'/Users/who/user-data/c2.bin.ts',
|
|
53
56
|
'--http',
|
|
54
57
|
'6666',
|
|
55
58
|
'user_data_dir',
|
|
@@ -61,7 +64,7 @@ test('parseArgs with --http bunk', () => {
|
|
|
61
64
|
expect(() =>
|
|
62
65
|
parseArgs([
|
|
63
66
|
'/Users/who/.bun/bin/bun',
|
|
64
|
-
'/Users/who/user-data/c2.ts',
|
|
67
|
+
'/Users/who/user-data/c2.bin.ts',
|
|
65
68
|
'--http',
|
|
66
69
|
'bunk',
|
|
67
70
|
'user_data_dir',
|
package/lib/cli.ts
CHANGED
|
@@ -12,7 +12,12 @@ export function parseArgs(args?: Array<string>): ParsedArgs {
|
|
|
12
12
|
args = process.argv
|
|
13
13
|
}
|
|
14
14
|
args = [...args]
|
|
15
|
-
|
|
15
|
+
let shifted
|
|
16
|
+
while ((shifted = args.shift())) {
|
|
17
|
+
if (shifted.endsWith('/c2.bin.js') || shifted.endsWith('/c2.bin.ts')) {
|
|
18
|
+
break
|
|
19
|
+
}
|
|
20
|
+
}
|
|
16
21
|
let base64 = false
|
|
17
22
|
let httpPort: number | undefined
|
|
18
23
|
let userData: Array<string> = []
|
package/lib/expression.spec.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeEach, expect, test } from 'bun:test'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
|
-
import { evalTemplateExpressions } from '
|
|
4
|
-
import { makeFile, makeTempDir, removeDir } from '
|
|
3
|
+
import { evalTemplateExpressions } from './expression.ts'
|
|
4
|
+
import { makeFile, makeTempDir, removeDir } from './fs.testing.ts'
|
|
5
5
|
|
|
6
6
|
let files: Array<string> = []
|
|
7
7
|
let tmpDir: string
|
package/lib/expression.ts
CHANGED
package/lib_js/attachments.js
CHANGED
package/lib_js/build.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { collectAttachments } from
|
|
2
|
-
import { evalTemplateExpressions } from
|
|
3
|
-
import { readToString } from
|
|
1
|
+
import { collectAttachments } from "./attachments.js";
|
|
2
|
+
import { evalTemplateExpressions } from "./expression.js";
|
|
3
|
+
import { readToString } from "./fs.js";
|
|
4
4
|
export async function buildUserData(userDataDir, opts) {
|
|
5
5
|
const attachments = await collectAttachments(userDataDir);
|
|
6
6
|
switch (attachments.length) {
|
package/lib_js/c2.api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { buildUserData } from
|
|
1
|
+
export { buildUserData } from "./build.js";
|
package/lib_js/c2.bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { buildUserData } from
|
|
3
|
-
import { parseArgs } from
|
|
4
|
-
import { doesDirExist } from
|
|
2
|
+
import { buildUserData } from "./build.js";
|
|
3
|
+
import { parseArgs } from "./cli.js";
|
|
4
|
+
import { doesDirExist } from "./fs.js";
|
|
5
5
|
let args;
|
|
6
6
|
try {
|
|
7
7
|
args = parseArgs();
|
package/lib_js/cli.js
CHANGED
|
@@ -3,7 +3,12 @@ export function parseArgs(args) {
|
|
|
3
3
|
args = process.argv;
|
|
4
4
|
}
|
|
5
5
|
args = [...args];
|
|
6
|
-
|
|
6
|
+
let shifted;
|
|
7
|
+
while ((shifted = args.shift())) {
|
|
8
|
+
if (shifted.endsWith('/c2.bin.js') || shifted.endsWith('/c2.bin.ts')) {
|
|
9
|
+
break;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
7
12
|
let base64 = false;
|
|
8
13
|
let httpPort;
|
|
9
14
|
let userData = [];
|
package/lib_js/expression.js
CHANGED
package/lib_types/c2.api.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { type BuildUserDataOpts, buildUserData } from '
|
|
1
|
+
export { type BuildUserDataOpts, buildUserData } from './build.ts';
|
|
2
2
|
//# sourceMappingURL=c2.api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"c2.api.d.ts","sourceRoot":"","sources":["../lib/c2.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"c2.api.d.ts","sourceRoot":"","sources":["../lib/c2.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
|
package/lib_types/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../lib/cli.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAChB;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GACd;IACI,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACtB,CAAA;AAEP,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../lib/cli.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAChB;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GACd;IACI,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACtB,CAAA;AAEP,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,UAAU,CA2C1D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eighty4/c2",
|
|
3
|
-
"version": "0.0.2-
|
|
3
|
+
"version": "0.0.2-25",
|
|
4
4
|
"author": "Adam McKee <adam.be.g84d@gmail.com>",
|
|
5
5
|
"repository": "https://github.com/eighty4/c2",
|
|
6
6
|
"homepage": "https://github.com/eighty4/c2",
|
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
"c2": "./lib_js/c2.bin.js"
|
|
24
24
|
},
|
|
25
25
|
"main": "./lib_js/c2.api.js",
|
|
26
|
-
"imports": {
|
|
27
|
-
"#c2/*.js": "./lib_js/*.js",
|
|
28
|
-
"#c2/*.ts": "./lib/*.ts"
|
|
29
|
-
},
|
|
30
26
|
"types": "./lib_types",
|
|
31
27
|
"scripts": {
|
|
32
28
|
"build": "tsc",
|