flightdeck 0.2.27 → 0.2.29
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/chunk-Cl8Af3a2.js +11 -0
- package/dist/flightdeck.lib-C59Q6GuJ.js +408 -0
- package/dist/flightdeck.lib-C59Q6GuJ.js.map +1 -0
- package/dist/flightdeck.x.js +110 -114
- package/dist/flightdeck.x.js.map +1 -1
- package/dist/klaxon.lib-CNw2A3ce.js +41 -0
- package/dist/klaxon.lib-CNw2A3ce.js.map +1 -0
- package/dist/klaxon.x.js +44 -49
- package/dist/klaxon.x.js.map +1 -1
- package/dist/lib.d.ts +1925 -927
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +4 -5
- package/package.json +12 -12
- package/src/flightdeck.lib.ts +0 -2
- package/dist/chunk-FIIAJE2K.js +0 -4780
- package/dist/chunk-FIIAJE2K.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-ZID4FJKY.js +0 -51
- package/dist/chunk-ZID4FJKY.js.map +0 -1
- package/dist/lib.js.map +0 -1
package/dist/flightdeck.x.js
CHANGED
|
@@ -1,123 +1,119 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { z } from 'zod';
|
|
2
|
+
import { FlightDeck, FlightDeckLogger } from "./flightdeck.lib-C59Q6GuJ.js";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { cli, optional, parseBooleanOption, parseNumberOption } from "comline";
|
|
5
|
+
import { z } from "zod";
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
7
|
+
//#region src/flightdeck.x.ts
|
|
8
|
+
const CLI_LOGGER = new FlightDeckLogger(`comline`, process.pid, void 0, { jsonLogging: true });
|
|
11
9
|
Object.assign(console, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
log: CLI_LOGGER.info.bind(CLI_LOGGER),
|
|
11
|
+
info: CLI_LOGGER.info.bind(CLI_LOGGER),
|
|
12
|
+
warn: CLI_LOGGER.warn.bind(CLI_LOGGER),
|
|
13
|
+
error: CLI_LOGGER.error.bind(CLI_LOGGER)
|
|
16
14
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
15
|
+
const FLIGHTDECK_MANUAL = {
|
|
16
|
+
optionsSchema: z.object({
|
|
17
|
+
port: z.number().optional(),
|
|
18
|
+
packageName: z.string(),
|
|
19
|
+
services: z.record(z.object({
|
|
20
|
+
run: z.string(),
|
|
21
|
+
waitFor: z.boolean()
|
|
22
|
+
})),
|
|
23
|
+
flightdeckRootDir: z.string(),
|
|
24
|
+
scripts: z.object({
|
|
25
|
+
download: z.string(),
|
|
26
|
+
install: z.string(),
|
|
27
|
+
checkAvailability: z.string()
|
|
28
|
+
}),
|
|
29
|
+
jsonLogging: z.boolean().optional()
|
|
30
|
+
}),
|
|
31
|
+
options: {
|
|
32
|
+
port: {
|
|
33
|
+
flag: `p`,
|
|
34
|
+
required: false,
|
|
35
|
+
description: `Port to run the flightdeck server on.`,
|
|
36
|
+
example: `--port=8080`,
|
|
37
|
+
parse: parseNumberOption
|
|
38
|
+
},
|
|
39
|
+
packageName: {
|
|
40
|
+
flag: `n`,
|
|
41
|
+
required: true,
|
|
42
|
+
description: `Name of the package.`,
|
|
43
|
+
example: `--packageName=\"my-app\"`
|
|
44
|
+
},
|
|
45
|
+
services: {
|
|
46
|
+
flag: `s`,
|
|
47
|
+
required: true,
|
|
48
|
+
description: `Map of service names to executables.`,
|
|
49
|
+
example: `--services="{\\"frontend\\":{\\"run\\":\\"./frontend\\",\\"waitFor\\":false},\\"backend\\":{\\"run\\":\\"./backend\\",\\"waitFor\\":true}}"`,
|
|
50
|
+
parse: JSON.parse
|
|
51
|
+
},
|
|
52
|
+
flightdeckRootDir: {
|
|
53
|
+
flag: `d`,
|
|
54
|
+
required: true,
|
|
55
|
+
description: `Directory where the service is stored.`,
|
|
56
|
+
example: `--flightdeckRootDir=\"./services/sample/repo/my-app/current\"`
|
|
57
|
+
},
|
|
58
|
+
scripts: {
|
|
59
|
+
flag: `r`,
|
|
60
|
+
required: true,
|
|
61
|
+
description: `Map of scripts to run.`,
|
|
62
|
+
example: `--scripts="{\\"download\\":\\"npm i",\\"install\\":\\"npm run build\\"}"`,
|
|
63
|
+
parse: JSON.parse
|
|
64
|
+
},
|
|
65
|
+
jsonLogging: {
|
|
66
|
+
flag: `j`,
|
|
67
|
+
required: false,
|
|
68
|
+
description: `Enable json logging.`,
|
|
69
|
+
example: `--jsonLogging`,
|
|
70
|
+
parse: parseBooleanOption
|
|
71
|
+
}
|
|
72
|
+
}
|
|
72
73
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
description: `Directory to write the schema to.`,
|
|
82
|
-
example: `--outdir=./dist`
|
|
83
|
-
}
|
|
84
|
-
}
|
|
74
|
+
const SCHEMA_MANUAL = {
|
|
75
|
+
optionsSchema: z.object({ outdir: z.string().optional() }),
|
|
76
|
+
options: { outdir: {
|
|
77
|
+
flag: `o`,
|
|
78
|
+
required: false,
|
|
79
|
+
description: `Directory to write the schema to.`,
|
|
80
|
+
example: `--outdir=./dist`
|
|
81
|
+
} }
|
|
85
82
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
);
|
|
106
|
-
var { inputs, writeJsonSchema } = parse(process.argv);
|
|
83
|
+
const parse = cli({
|
|
84
|
+
cliName: `flightdeck`,
|
|
85
|
+
routes: optional({
|
|
86
|
+
schema: null,
|
|
87
|
+
$configPath: null
|
|
88
|
+
}),
|
|
89
|
+
routeOptions: {
|
|
90
|
+
"": FLIGHTDECK_MANUAL,
|
|
91
|
+
$configPath: FLIGHTDECK_MANUAL,
|
|
92
|
+
schema: SCHEMA_MANUAL
|
|
93
|
+
},
|
|
94
|
+
debugOutput: true,
|
|
95
|
+
discoverConfigPath: (args) => {
|
|
96
|
+
if (args[0] === `schema`) return;
|
|
97
|
+
const configPath = args[0] ?? path.join(process.cwd(), `flightdeck.config.json`);
|
|
98
|
+
return configPath;
|
|
99
|
+
}
|
|
100
|
+
}, console);
|
|
101
|
+
const { inputs, writeJsonSchema } = parse(process.argv);
|
|
107
102
|
switch (inputs.case) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
103
|
+
case `schema`:
|
|
104
|
+
{
|
|
105
|
+
const { outdir } = inputs.opts;
|
|
106
|
+
writeJsonSchema(outdir ?? `.`);
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case ``:
|
|
110
|
+
case `$configPath`: {
|
|
111
|
+
const flightDeck = new FlightDeck(inputs.opts);
|
|
112
|
+
process.on(`close`, async () => {
|
|
113
|
+
await flightDeck.stopAllServices();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
121
116
|
}
|
|
122
|
-
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
123
119
|
//# sourceMappingURL=flightdeck.x.js.map
|
package/dist/flightdeck.x.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"flightdeck.x.js","names":[],"sources":["../src/flightdeck.x.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\"\n\nimport type { OptionsGroup } from \"comline\"\nimport { cli, optional, parseBooleanOption, parseNumberOption } from \"comline\"\nimport { z } from \"zod\"\n\nimport type { FlightDeckOptions } from \"./flightdeck.lib\"\nimport { FlightDeck, FlightDeckLogger } from \"./flightdeck.lib\"\n\nconst CLI_LOGGER = new FlightDeckLogger(`comline`, process.pid, undefined, {\n\tjsonLogging: true,\n})\nObject.assign(console, {\n\tlog: CLI_LOGGER.info.bind(CLI_LOGGER),\n\tinfo: CLI_LOGGER.info.bind(CLI_LOGGER),\n\twarn: CLI_LOGGER.warn.bind(CLI_LOGGER),\n\terror: CLI_LOGGER.error.bind(CLI_LOGGER),\n})\n\nconst FLIGHTDECK_MANUAL = {\n\toptionsSchema: z.object({\n\t\tport: z.number().optional(),\n\t\tpackageName: z.string(),\n\t\tservices: z.record(z.object({ run: z.string(), waitFor: z.boolean() })),\n\t\tflightdeckRootDir: z.string(),\n\t\tscripts: z.object({\n\t\t\tdownload: z.string(),\n\t\t\tinstall: z.string(),\n\t\t\tcheckAvailability: z.string(),\n\t\t}),\n\t\tjsonLogging: z.boolean().optional(),\n\t}),\n\toptions: {\n\t\tport: {\n\t\t\tflag: `p`,\n\t\t\trequired: false,\n\t\t\tdescription: `Port to run the flightdeck server on.`,\n\t\t\texample: `--port=8080`,\n\t\t\tparse: parseNumberOption,\n\t\t},\n\t\tpackageName: {\n\t\t\tflag: `n`,\n\t\t\trequired: true,\n\t\t\tdescription: `Name of the package.`,\n\t\t\texample: `--packageName=\\\"my-app\\\"`,\n\t\t},\n\t\tservices: {\n\t\t\tflag: `s`,\n\t\t\trequired: true,\n\t\t\tdescription: `Map of service names to executables.`,\n\t\t\texample: `--services=\"{\\\\\"frontend\\\\\":{\\\\\"run\\\\\":\\\\\"./frontend\\\\\",\\\\\"waitFor\\\\\":false},\\\\\"backend\\\\\":{\\\\\"run\\\\\":\\\\\"./backend\\\\\",\\\\\"waitFor\\\\\":true}}\"`,\n\t\t\tparse: JSON.parse,\n\t\t},\n\t\tflightdeckRootDir: {\n\t\t\tflag: `d`,\n\t\t\trequired: true,\n\t\t\tdescription: `Directory where the service is stored.`,\n\t\t\texample: `--flightdeckRootDir=\\\"./services/sample/repo/my-app/current\\\"`,\n\t\t},\n\t\tscripts: {\n\t\t\tflag: `r`,\n\t\t\trequired: true,\n\t\t\tdescription: `Map of scripts to run.`,\n\t\t\texample: `--scripts=\"{\\\\\"download\\\\\":\\\\\"npm i\",\\\\\"install\\\\\":\\\\\"npm run build\\\\\"}\"`,\n\t\t\tparse: JSON.parse,\n\t\t},\n\t\tjsonLogging: {\n\t\t\tflag: `j`,\n\t\t\trequired: false,\n\t\t\tdescription: `Enable json logging.`,\n\t\t\texample: `--jsonLogging`,\n\t\t\tparse: parseBooleanOption,\n\t\t},\n\t},\n} satisfies OptionsGroup<FlightDeckOptions>\n\nconst SCHEMA_MANUAL = {\n\toptionsSchema: z.object({\n\t\toutdir: z.string().optional(),\n\t}),\n\toptions: {\n\t\toutdir: {\n\t\t\tflag: `o`,\n\t\t\trequired: false,\n\t\t\tdescription: `Directory to write the schema to.`,\n\t\t\texample: `--outdir=./dist`,\n\t\t},\n\t},\n} satisfies OptionsGroup<{ outdir?: string | undefined }>\n\nconst parse = cli(\n\t{\n\t\tcliName: `flightdeck`,\n\t\troutes: optional({ schema: null, $configPath: null }),\n\t\trouteOptions: {\n\t\t\t\"\": FLIGHTDECK_MANUAL,\n\t\t\t$configPath: FLIGHTDECK_MANUAL,\n\t\t\tschema: SCHEMA_MANUAL,\n\t\t},\n\t\tdebugOutput: true,\n\t\tdiscoverConfigPath: (args) => {\n\t\t\tif (args[0] === `schema`) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst configPath =\n\t\t\t\targs[0] ?? path.join(process.cwd(), `flightdeck.config.json`)\n\t\t\treturn configPath\n\t\t},\n\t},\n\tconsole,\n)\n\nconst { inputs, writeJsonSchema } = parse(process.argv)\n\nswitch (inputs.case) {\n\tcase `schema`:\n\t\t{\n\t\t\tconst { outdir } = inputs.opts\n\t\t\twriteJsonSchema(outdir ?? `.`)\n\t\t}\n\t\tbreak\n\tcase ``:\n\tcase `$configPath`: {\n\t\tconst flightDeck = new FlightDeck(inputs.opts)\n\t\tprocess.on(`close`, async () => {\n\t\t\tawait flightDeck.stopAllServices()\n\t\t})\n\t}\n}\n"],"mappings":";;;;;;;AAWA,MAAM,aAAa,IAAI,kBAAkB,UAAU,QAAQ,aAAgB,EAC1E,aAAa,KACb;AACD,OAAO,OAAO,SAAS;CACtB,KAAK,WAAW,KAAK,KAAK,WAAW;CACrC,MAAM,WAAW,KAAK,KAAK,WAAW;CACtC,MAAM,WAAW,KAAK,KAAK,WAAW;CACtC,OAAO,WAAW,MAAM,KAAK,WAAW;AACxC,EAAC;AAEF,MAAM,oBAAoB;CACzB,eAAe,EAAE,OAAO;EACvB,MAAM,EAAE,QAAQ,CAAC,UAAU;EAC3B,aAAa,EAAE,QAAQ;EACvB,UAAU,EAAE,OAAO,EAAE,OAAO;GAAE,KAAK,EAAE,QAAQ;GAAE,SAAS,EAAE,SAAS;EAAE,EAAC,CAAC;EACvE,mBAAmB,EAAE,QAAQ;EAC7B,SAAS,EAAE,OAAO;GACjB,UAAU,EAAE,QAAQ;GACpB,SAAS,EAAE,QAAQ;GACnB,mBAAmB,EAAE,QAAQ;EAC7B,EAAC;EACF,aAAa,EAAE,SAAS,CAAC,UAAU;CACnC,EAAC;CACF,SAAS;EACR,MAAM;GACL,OAAO;GACP,UAAU;GACV,cAAc;GACd,UAAU;GACV,OAAO;EACP;EACD,aAAa;GACZ,OAAO;GACP,UAAU;GACV,cAAc;GACd,UAAU;EACV;EACD,UAAU;GACT,OAAO;GACP,UAAU;GACV,cAAc;GACd,UAAU;GACV,OAAO,KAAK;EACZ;EACD,mBAAmB;GAClB,OAAO;GACP,UAAU;GACV,cAAc;GACd,UAAU;EACV;EACD,SAAS;GACR,OAAO;GACP,UAAU;GACV,cAAc;GACd,UAAU;GACV,OAAO,KAAK;EACZ;EACD,aAAa;GACZ,OAAO;GACP,UAAU;GACV,cAAc;GACd,UAAU;GACV,OAAO;EACP;CACD;AACD;AAED,MAAM,gBAAgB;CACrB,eAAe,EAAE,OAAO,EACvB,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAC7B,EAAC;CACF,SAAS,EACR,QAAQ;EACP,OAAO;EACP,UAAU;EACV,cAAc;EACd,UAAU;CACV,EACD;AACD;AAED,MAAM,QAAQ,IACb;CACC,UAAU;CACV,QAAQ,SAAS;EAAE,QAAQ;EAAM,aAAa;CAAM,EAAC;CACrD,cAAc;EACb,IAAI;EACJ,aAAa;EACb,QAAQ;CACR;CACD,aAAa;CACb,oBAAoB,CAAC,SAAS;AAC7B,MAAI,KAAK,QAAQ,QAChB;EAED,MAAM,aACL,KAAK,MAAM,KAAK,KAAK,QAAQ,KAAK,GAAG,wBAAwB;AAC9D,SAAO;CACP;AACD,GACD,QACA;AAED,MAAM,EAAE,QAAQ,iBAAiB,GAAG,MAAM,QAAQ,KAAK;AAEvD,QAAQ,OAAO,MAAf;CACC,MAAM;EACL;GACC,MAAM,EAAE,QAAQ,GAAG,OAAO;AAC1B,mBAAgB,WAAW,GAAG;EAC9B;AACD;CACD,MAAM;CACN,MAAM,cAAc;EACnB,MAAM,aAAa,IAAI,WAAW,OAAO;AACzC,UAAQ,IAAI,QAAQ,YAAY;AAC/B,SAAM,WAAW,iBAAiB;EAClC,EAAC;CACF;AACD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __export } from "./chunk-Cl8Af3a2.js";
|
|
2
|
+
|
|
3
|
+
//#region src/klaxon.lib.ts
|
|
4
|
+
var klaxon_lib_exports = {};
|
|
5
|
+
__export(klaxon_lib_exports, {
|
|
6
|
+
alert: () => alert,
|
|
7
|
+
scramble: () => scramble
|
|
8
|
+
});
|
|
9
|
+
async function alert({ secret, endpoint, version }) {
|
|
10
|
+
const response = await fetch(endpoint, {
|
|
11
|
+
method: `POST`,
|
|
12
|
+
headers: {
|
|
13
|
+
"Content-Type": `text/plain;charset=UTF-8`,
|
|
14
|
+
Authorization: `Bearer ${secret}`
|
|
15
|
+
},
|
|
16
|
+
body: version
|
|
17
|
+
});
|
|
18
|
+
return response;
|
|
19
|
+
}
|
|
20
|
+
async function scramble({ packageConfig, secretsConfig, publishedPackages }) {
|
|
21
|
+
const alertResults = [];
|
|
22
|
+
for (const publishedPackage of publishedPackages) if (publishedPackage.name in packageConfig) {
|
|
23
|
+
const name = publishedPackage.name;
|
|
24
|
+
const { endpoint } = packageConfig[name];
|
|
25
|
+
const secret = secretsConfig[name];
|
|
26
|
+
const version = publishedPackage.version;
|
|
27
|
+
const alertResultPromise = alert({
|
|
28
|
+
secret,
|
|
29
|
+
endpoint,
|
|
30
|
+
version
|
|
31
|
+
}).then((alertResult) => [name, alertResult]);
|
|
32
|
+
alertResults.push(alertResultPromise);
|
|
33
|
+
}
|
|
34
|
+
const alertResultsResolved = await Promise.all(alertResults);
|
|
35
|
+
const scrambleResult = Object.fromEntries(alertResultsResolved);
|
|
36
|
+
return scrambleResult;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { klaxon_lib_exports, scramble };
|
|
41
|
+
//# sourceMappingURL=klaxon.lib-CNw2A3ce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"klaxon.lib-CNw2A3ce.js","names":["alertResults: Promise<readonly [K, Response]>[]"],"sources":["../src/klaxon.lib.ts"],"sourcesContent":["export type AlertOptions = {\n\tsecret: string\n\tendpoint: string\n\tversion: string\n}\n\nexport async function alert({\n\tsecret,\n\tendpoint,\n\tversion,\n}: AlertOptions): Promise<Response> {\n\tconst response = await fetch(endpoint, {\n\t\tmethod: `POST`,\n\t\theaders: {\n\t\t\t\"Content-Type\": `text/plain;charset=UTF-8`,\n\t\t\tAuthorization: `Bearer ${secret}`,\n\t\t},\n\t\tbody: version,\n\t})\n\n\treturn response\n}\n\n/**\n * @see https://github.com/changesets/action/blob/main/src/run.ts\n */\nexport type ChangesetsPublishedPackage = {\n\tname: string\n\tversion: string\n}\n\n/**\n * @see https://github.com/changesets/action/blob/main/src/run.ts\n */\nexport type ChangesetsPublishResult =\n\t| {\n\t\t\tpublished: true\n\t\t\tpublishedPackages: ChangesetsPublishedPackage[]\n\t }\n\t| { published: false }\n\nexport type PackageConfig<K extends string> = {\n\t[key in K]: { endpoint: string }\n}\nexport type SecretsConfig<K extends string> = {\n\t[key in K]: string\n}\n\nexport type ScrambleOptions<K extends string = string> = {\n\tpackageConfig: PackageConfig<K>\n\tsecretsConfig: SecretsConfig<K>\n\tpublishedPackages: ChangesetsPublishedPackage[]\n}\n\nexport type ScrambleResult<K extends string = string> = {\n\t[key in K]: Response\n}\n\nexport async function scramble<K extends string = string>({\n\tpackageConfig,\n\tsecretsConfig,\n\tpublishedPackages,\n}: ScrambleOptions<K>): Promise<ScrambleResult<K>> {\n\tconst alertResults: Promise<readonly [K, Response]>[] = []\n\tfor (const publishedPackage of publishedPackages) {\n\t\tif (publishedPackage.name in packageConfig) {\n\t\t\tconst name = publishedPackage.name as K\n\t\t\tconst { endpoint } = packageConfig[name]\n\t\t\tconst secret = secretsConfig[name]\n\t\t\tconst version = publishedPackage.version\n\t\t\tconst alertResultPromise = alert({ secret, endpoint, version }).then(\n\t\t\t\t(alertResult) => [name, alertResult] as const,\n\t\t\t)\n\t\t\talertResults.push(alertResultPromise)\n\t\t}\n\t}\n\tconst alertResultsResolved = await Promise.all(alertResults)\n\tconst scrambleResult = Object.fromEntries(\n\t\talertResultsResolved,\n\t) as ScrambleResult<K>\n\treturn scrambleResult\n}\n"],"mappings":";;;;;;;;AAMA,eAAsB,MAAM,EAC3B,QACA,UACA,SACc,EAAqB;CACnC,MAAM,WAAW,MAAM,MAAM,UAAU;EACtC,SAAS;EACT,SAAS;GACR,iBAAiB;GACjB,gBAAgB,SAAS,OAAO;EAChC;EACD,MAAM;CACN,EAAC;AAEF,QAAO;AACP;AAqCD,eAAsB,SAAoC,EACzD,eACA,eACA,mBACoB,EAA8B;CAClD,MAAMA,eAAkD,CAAE;AAC1D,MAAK,MAAM,oBAAoB,kBAC9B,KAAI,iBAAiB,QAAQ,eAAe;EAC3C,MAAM,OAAO,iBAAiB;EAC9B,MAAM,EAAE,UAAU,GAAG,cAAc;EACnC,MAAM,SAAS,cAAc;EAC7B,MAAM,UAAU,iBAAiB;EACjC,MAAM,qBAAqB,MAAM;GAAE;GAAQ;GAAU;EAAS,EAAC,CAAC,KAC/D,CAAC,gBAAgB,CAAC,MAAM,WAAY,EACpC;AACD,eAAa,KAAK,mBAAmB;CACrC;CAEF,MAAM,uBAAuB,MAAM,QAAQ,IAAI,aAAa;CAC5D,MAAM,iBAAiB,OAAO,YAC7B,qBACA;AACD,QAAO;AACP"}
|
package/dist/klaxon.x.js
CHANGED
|
@@ -1,56 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { scramble } from
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { z } from 'zod';
|
|
2
|
+
import { scramble } from "./klaxon.lib-CNw2A3ce.js";
|
|
3
|
+
import { cli, required } from "comline";
|
|
4
|
+
import { z } from "zod";
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
6
|
+
//#region src/klaxon.x.ts
|
|
7
|
+
const changesetsPublishedPackagesSchema = z.object({
|
|
8
|
+
packageConfig: z.record(z.string(), z.object({ endpoint: z.string() })),
|
|
9
|
+
secretsConfig: z.record(z.string(), z.string()),
|
|
10
|
+
publishedPackages: z.array(z.object({
|
|
11
|
+
name: z.string(),
|
|
12
|
+
version: z.string()
|
|
13
|
+
}))
|
|
16
14
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
optionsSchema: changesetsPublishedPackagesSchema
|
|
48
|
-
}
|
|
49
|
-
}
|
|
15
|
+
const klaxon = cli({
|
|
16
|
+
cliName: `klaxon`,
|
|
17
|
+
routes: required({ scramble: null }),
|
|
18
|
+
routeOptions: { scramble: {
|
|
19
|
+
options: {
|
|
20
|
+
packageConfig: {
|
|
21
|
+
description: `Maps the names of your packages to the endpoints that klaxon will POST to.`,
|
|
22
|
+
example: `--packageConfig="{\\"my-app\\":{\\"endpoint\\":\\"https://my-app.com\\"}}"`,
|
|
23
|
+
flag: `c`,
|
|
24
|
+
parse: JSON.parse,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
secretsConfig: {
|
|
28
|
+
description: `Maps the names of your packages to the secrets that klaxon will use to authenticate with their respective endpoints.`,
|
|
29
|
+
example: `--secretsConfig="{\\"my-app\\":\\"XXXX-XXXX-XXXX\\"}"`,
|
|
30
|
+
flag: `s`,
|
|
31
|
+
parse: JSON.parse,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
publishedPackages: {
|
|
35
|
+
description: `The output of the "Publish" step in Changesets.`,
|
|
36
|
+
example: `--publishedPackages="[{\\"name\\":\\"my-app\\",\\"version\\":\\"0.0.0\\"}]"`,
|
|
37
|
+
flag: `p`,
|
|
38
|
+
parse: JSON.parse,
|
|
39
|
+
required: true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
optionsSchema: changesetsPublishedPackagesSchema
|
|
43
|
+
} }
|
|
50
44
|
});
|
|
51
|
-
|
|
45
|
+
const { inputs } = klaxon(process.argv);
|
|
52
46
|
await scramble(inputs.opts).then((scrambleResult) => {
|
|
53
|
-
|
|
47
|
+
console.log(scrambleResult);
|
|
54
48
|
});
|
|
55
|
-
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
56
51
|
//# sourceMappingURL=klaxon.x.js.map
|
package/dist/klaxon.x.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"klaxon.x.js","names":["changesetsPublishedPackagesSchema: z.ZodSchema<Klaxon.ScrambleOptions>"],"sources":["../src/klaxon.x.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { cli, required } from \"comline\"\nimport { z } from \"zod\"\n\nimport * as Klaxon from \"./klaxon.lib\"\n\nconst changesetsPublishedPackagesSchema: z.ZodSchema<Klaxon.ScrambleOptions> =\n\tz.object({\n\t\tpackageConfig: z.record(z.string(), z.object({ endpoint: z.string() })),\n\t\tsecretsConfig: z.record(z.string(), z.string()),\n\t\tpublishedPackages: z.array(\n\t\t\tz.object({\n\t\t\t\tname: z.string(),\n\t\t\t\tversion: z.string(),\n\t\t\t}),\n\t\t),\n\t})\n\nconst klaxon = cli({\n\tcliName: `klaxon`,\n\troutes: required({\n\t\tscramble: null,\n\t}),\n\trouteOptions: {\n\t\tscramble: {\n\t\t\toptions: {\n\t\t\t\tpackageConfig: {\n\t\t\t\t\tdescription: `Maps the names of your packages to the endpoints that klaxon will POST to.`,\n\t\t\t\t\texample: `--packageConfig=\"{\\\\\"my-app\\\\\":{\\\\\"endpoint\\\\\":\\\\\"https://my-app.com\\\\\"}}\"`,\n\t\t\t\t\tflag: `c`,\n\t\t\t\t\tparse: JSON.parse,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\tsecretsConfig: {\n\t\t\t\t\tdescription: `Maps the names of your packages to the secrets that klaxon will use to authenticate with their respective endpoints.`,\n\t\t\t\t\texample: `--secretsConfig=\"{\\\\\"my-app\\\\\":\\\\\"XXXX-XXXX-XXXX\\\\\"}\"`,\n\t\t\t\t\tflag: `s`,\n\t\t\t\t\tparse: JSON.parse,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\tpublishedPackages: {\n\t\t\t\t\tdescription: `The output of the \"Publish\" step in Changesets.`,\n\t\t\t\t\texample: `--publishedPackages=\"[{\\\\\"name\\\\\":\\\\\"my-app\\\\\",\\\\\"version\\\\\":\\\\\"0.0.0\\\\\"}]\"`,\n\t\t\t\t\tflag: `p`,\n\t\t\t\t\tparse: JSON.parse,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\toptionsSchema: changesetsPublishedPackagesSchema,\n\t\t},\n\t},\n})\n\nconst { inputs } = klaxon(process.argv)\nawait Klaxon.scramble(inputs.opts).then((scrambleResult) => {\n\tconsole.log(scrambleResult)\n})\n"],"mappings":";;;;;;AAOA,MAAMA,oCACL,EAAE,OAAO;CACR,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAE,EAAC,CAAC;CACvE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC;CAC/C,mBAAmB,EAAE,MACpB,EAAE,OAAO;EACR,MAAM,EAAE,QAAQ;EAChB,SAAS,EAAE,QAAQ;CACnB,EAAC,CACF;AACD,EAAC;AAEH,MAAM,SAAS,IAAI;CAClB,UAAU;CACV,QAAQ,SAAS,EAChB,UAAU,KACV,EAAC;CACF,cAAc,EACb,UAAU;EACT,SAAS;GACR,eAAe;IACd,cAAc;IACd,UAAU;IACV,OAAO;IACP,OAAO,KAAK;IACZ,UAAU;GACV;GACD,eAAe;IACd,cAAc;IACd,UAAU;IACV,OAAO;IACP,OAAO,KAAK;IACZ,UAAU;GACV;GACD,mBAAmB;IAClB,cAAc;IACd,UAAU;IACV,OAAO;IACP,OAAO,KAAK;IACZ,UAAU;GACV;EACD;EACD,eAAe;CACf,EACD;AACD,EAAC;AAEF,MAAM,EAAE,QAAQ,GAAG,OAAO,QAAQ,KAAK;AACvC,MAAM,SAAgB,OAAO,KAAK,CAAC,KAAK,CAAC,mBAAmB;AAC3D,SAAQ,IAAI,eAAe;AAC3B,EAAC"}
|