rbxts-orchestra 0.1.0-dev.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/run ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../dist/run')
package/dist/run.js ADDED
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+
29
+ // bin/run.ts
30
+ var import_yargs = __toESM(require("yargs"));
31
+
32
+ // package.json
33
+ var package_default = {
34
+ name: "rbxts-orchestra",
35
+ version: "0.1.0",
36
+ description: "A build orchestrator.",
37
+ main: "src/index.ts",
38
+ bin: {
39
+ orchestra: "./bin/run"
40
+ },
41
+ directories: {
42
+ lib: "src",
43
+ bin: "bin"
44
+ },
45
+ files: [
46
+ "dist",
47
+ "bin/run"
48
+ ],
49
+ scripts: {
50
+ build: "tsup-node && tsc",
51
+ "build:watch": "tsup-node --watch",
52
+ clean: "rimraf dist",
53
+ compile: "tsc",
54
+ format: "prettier . --check",
55
+ "format:fix": "prettier . --write",
56
+ lint: "eslint .",
57
+ "lint:fix": "eslint . --fix",
58
+ start: "ts-node ./bin/run.ts",
59
+ "start:node": "node ./bin/run",
60
+ prepublish: "npm run build"
61
+ },
62
+ devDependencies: {
63
+ "@tsconfig/node20": "^20.1.4",
64
+ "@types/node": "^20.12.12",
65
+ "@types/yargs": "^17.0.32",
66
+ eslint: "^9.39.2",
67
+ "eslint-config-prettier": "^10.1.8",
68
+ "eslint-plugin-import": "^2.32.0",
69
+ "eslint-plugin-prettier": "^5.5.4",
70
+ "eslint-plugin-unused-imports": "^4.3.0",
71
+ prettier: "^3.7.4",
72
+ rimraf: "^5.0.7",
73
+ "ts-node": "^10.9.2",
74
+ tsup: "^8.0.2",
75
+ typescript: "^5.5.3",
76
+ "typescript-eslint": "^8.51.0"
77
+ },
78
+ dependencies: {
79
+ consola: "^3.2.3",
80
+ picocolors: "^1.0.1",
81
+ yargs: "^17.7.2",
82
+ jiti: "^2.6.1"
83
+ }
84
+ };
85
+
86
+ // src/commands/runScript.ts
87
+ var runScript_exports = {};
88
+ __export(runScript_exports, {
89
+ builder: () => builder,
90
+ command: () => command,
91
+ describe: () => describe,
92
+ handler: () => handler
93
+ });
94
+ var import_node_path = require("path");
95
+ var process2 = __toESM(require("process"));
96
+
97
+ // src/logger.ts
98
+ var import_consola = require("consola");
99
+ var logger = (0, import_consola.createConsola)({});
100
+
101
+ // src/orchestra/config.ts
102
+ function resolveValue(value, orchestra) {
103
+ return typeof value === "function" ? value(orchestra) : value;
104
+ }
105
+
106
+ // src/orchestra/orchestra.ts
107
+ var import_assert = __toESM(require("assert"));
108
+ var import_jiti = require("jiti");
109
+ var import_path = require("path");
110
+ var jiti = (0, import_jiti.createJiti)(__filename);
111
+ var ORCHESTRA_CONFIG_FILENAME = "orchestra.config.ts";
112
+ var Orchestra = class _Orchestra {
113
+ constructor(config) {
114
+ this.config = config;
115
+ for (const [environmentName, environmentConfig] of Object.entries(config.environments)) {
116
+ if (this.environment) continue;
117
+ const NODE_ENV = process.env.NODE_ENV ?? "unknown";
118
+ if (environmentConfig.default) {
119
+ this.environment = environmentName;
120
+ } else if (NODE_ENV == environmentConfig.nodeEnv) {
121
+ this.environment = environmentName;
122
+ }
123
+ }
124
+ (0, import_assert.default)(this.environment, `Orchestra confiag is invalid, no default or otherwise valid environments provided`);
125
+ }
126
+ static async fromDirectory(directoryPath) {
127
+ return await _Orchestra.fromFileConfig((0, import_path.resolve)(directoryPath, ORCHESTRA_CONFIG_FILENAME));
128
+ }
129
+ static async fromFileConfig(filePath) {
130
+ const config = await jiti.import((0, import_path.resolve)(filePath), {
131
+ default: true
132
+ });
133
+ return new _Orchestra(config);
134
+ }
135
+ environment;
136
+ async runScripts(scriptName, argv2) {
137
+ await this.resolveConfig(this.config.scripts?.prepare)?.(this, void 0, argv2);
138
+ await this.resolveConfig(this.config.scripts?.[scriptName])?.(this, void 0, argv2);
139
+ for (const place of this.config.places) {
140
+ await this.resolveConfig(place.scripts[scriptName])?.(this, place, argv2);
141
+ }
142
+ }
143
+ resolveConfig(config) {
144
+ return resolveValue(config, this);
145
+ }
146
+ };
147
+
148
+ // src/commands/runScript.ts
149
+ var command = "run <script>";
150
+ var describe = "Runs build scripts for all orchestrated places.";
151
+ function builder(yargs2) {
152
+ return yargs2.positional("script", {
153
+ type: "string",
154
+ description: "script name"
155
+ }).option("config", {
156
+ type: "string",
157
+ alias: "c",
158
+ description: "Path to the orchestra config file",
159
+ default: `${ORCHESTRA_CONFIG_FILENAME}`
160
+ }).coerce("config", (value) => {
161
+ if ((0, import_node_path.isAbsolute)(value)) {
162
+ return value;
163
+ }
164
+ return (0, import_node_path.join)(process2.cwd(), value);
165
+ });
166
+ }
167
+ async function handler(argv2) {
168
+ const delimiterIndex = process2.argv.findIndex((arg) => arg == "--");
169
+ const delimitedArgv = delimiterIndex !== -1 ? process2.argv.slice(delimiterIndex + 1) : void 0;
170
+ const orchestra = await Orchestra.fromFileConfig(argv2.config).catch(() => {
171
+ logger.error(`Failed to find config file at ${argv2.config}`);
172
+ process2.exit(1);
173
+ });
174
+ await orchestra.runScripts(argv2.script, delimitedArgv).catch((code) => {
175
+ logger.error(`Failed to run script: exit code ${code}`);
176
+ });
177
+ }
178
+
179
+ // src/commands/index.ts
180
+ var commands = [runScript_exports];
181
+
182
+ // src/helpers/release.ts
183
+ var import_child_process = require("child_process");
184
+
185
+ // src/helpers/script.ts
186
+ var import_child_process2 = require("child_process");
187
+ var import_path2 = require("path");
188
+
189
+ // bin/run.ts
190
+ var run = (0, import_yargs.default)(process.argv.slice(2));
191
+ run.usage(`orchestra v${package_default.version}`);
192
+ for (const command2 of commands) {
193
+ run.command(command2);
194
+ }
195
+ run.demandCommand(1, "You need at least one command before moving on").help().argv;
@@ -0,0 +1,2 @@
1
+ import * as run from "./runScript";
2
+ export declare const commands: (typeof run)[];
@@ -0,0 +1,3 @@
1
+ import * as run from "./runScript";
2
+ export const commands = [run];
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ArgumentsCamelCase, Argv } from "yargs";
2
+ interface RunArgv {
3
+ script: string;
4
+ config: string;
5
+ }
6
+ export declare const command = "run <script>";
7
+ export declare const describe = "Runs build scripts for all orchestrated places.";
8
+ export declare function builder(yargs: Argv<RunArgv>): Argv;
9
+ export declare function handler(argv: ArgumentsCamelCase<RunArgv>): Promise<void>;
10
+ export {};
@@ -0,0 +1,37 @@
1
+ import { isAbsolute, join } from "node:path";
2
+ import * as process from "node:process";
3
+ import { logger } from "../logger";
4
+ import { Orchestra, ORCHESTRA_CONFIG_FILENAME } from "../orchestra";
5
+ export const command = "run <script>";
6
+ export const describe = "Runs build scripts for all orchestrated places.";
7
+ export function builder(yargs) {
8
+ return yargs
9
+ .positional("script", {
10
+ type: "string",
11
+ description: "script name",
12
+ })
13
+ .option("config", {
14
+ type: "string",
15
+ alias: "c",
16
+ description: "Path to the orchestra config file",
17
+ default: `${ORCHESTRA_CONFIG_FILENAME}`,
18
+ })
19
+ .coerce("config", (value) => {
20
+ if (isAbsolute(value)) {
21
+ return value;
22
+ }
23
+ return join(process.cwd(), value);
24
+ });
25
+ }
26
+ export async function handler(argv) {
27
+ const delimiterIndex = process.argv.findIndex((arg) => arg == "--");
28
+ const delimitedArgv = delimiterIndex !== -1 ? process.argv.slice(delimiterIndex + 1) : undefined;
29
+ const orchestra = await Orchestra.fromFileConfig(argv.config).catch(() => {
30
+ logger.error(`Failed to find config file at ${argv.config}`);
31
+ process.exit(1);
32
+ });
33
+ await orchestra.runScripts(argv.script, delimitedArgv).catch((code) => {
34
+ logger.error(`Failed to run script: exit code ${code}`);
35
+ });
36
+ }
37
+ //# sourceMappingURL=runScript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runScript.js","sourceRoot":"","sources":["../../../src/commands/runScript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAOpE,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC;AACtC,MAAM,CAAC,MAAM,QAAQ,GAAG,iDAAiD,CAAC;AAE1E,MAAM,UAAU,OAAO,CAAC,KAAoB;IAC3C,OAAO,K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I,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Environments, Value } from "src/orchestra";
2
+ export declare function semverString<E extends Environments>(
3
+ /**
4
+ * The base semver string (e.g `1.0.0`)
5
+ */
6
+ baseSemver: string,
7
+ /**
8
+ * A list of environments in which to include the short hash of the
9
+ * currently checked out commit in the semver string
10
+ */
11
+ commitHashEnvironments?: (keyof E)[],
12
+ /**
13
+ * A list of environments in which to include the name of the
14
+ * local user in the semver string
15
+ */
16
+ userEnvironments?: (keyof E)[]): Value<E, string>;
@@ -0,0 +1,42 @@
1
+ import { execSync } from "child_process";
2
+ export function semverString(
3
+ /**
4
+ * The base semver string (e.g `1.0.0`)
5
+ */
6
+ baseSemver,
7
+ /**
8
+ * A list of environments in which to include the short hash of the
9
+ * currently checked out commit in the semver string
10
+ */
11
+ commitHashEnvironments,
12
+ /**
13
+ * A list of environments in which to include the name of the
14
+ * local user in the semver string
15
+ */
16
+ userEnvironments) {
17
+ return (orchestra) => {
18
+ let shortCommitHash, localUsername;
19
+ try {
20
+ localUsername = execSync("whoami", {
21
+ stdio: "pipe",
22
+ })
23
+ .toString()
24
+ .trim();
25
+ shortCommitHash = execSync("git rev-parse --short HEAD", {
26
+ stdio: "pipe",
27
+ })
28
+ .toString()
29
+ .trim();
30
+ }
31
+ catch { }
32
+ let semver = baseSemver;
33
+ if (localUsername && userEnvironments?.includes(orchestra.environment)) {
34
+ semver += `-${localUsername}`;
35
+ }
36
+ if (shortCommitHash && commitHashEnvironments?.includes(orchestra.environment)) {
37
+ semver += `+${shortCommitHash}`;
38
+ }
39
+ return semver;
40
+ };
41
+ }
42
+ //# sourceMappingURL=release.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release.js","sourceRoot":"","sources":["../../../src/helpers/release.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,UAAU,YAAY;AAC3B;;GAEG;AACH,UAAkB;AAClB;;;GAGG;AACH,sBAAoC;AACpC;;;GAGG;AACH,gBAA8B;IAE9B,OAAO,CAAC,SAAS,EAAE,EAAE;QACpB,IAAI,eAAe,EAAE,aAAa,CAAC;QACnC,IAAI,CAAC;YACJ,aAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE;gBAClC,KAAK,EAAE,MAAM;aACb,CAAC;iBACA,QAAQ,EAAE;iBACV,IAAI,EAAE,CAAC;YACT,eAAe,GAAG,QAAQ,CAAC,4BAA4B,EAAE;gBACxD,KAAK,EAAE,MAAM;aACb,CAAC;iBACA,QAAQ,EAAE;iBACV,IAAI,EAAE,CAAC;QACV,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,IAAI,MAAM,GAAG,UAAU,CAAC;QAExB,IAAI,aAAa,IAAI,gBAAgB,EAAE,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QAC/B,CAAC;QACD,IAAI,eAAe,IAAI,sBAAsB,EAAE,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;YAChF,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;QACjC,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Environments, Script, Value } from "../orchestra/config";
2
+ interface SpawnConfig {
3
+ /**
4
+ * Whether to wait until the process exits before continuing to the next script
5
+ */
6
+ waitForExit: boolean;
7
+ /**
8
+ * Whether to ignore a non-zero exit code
9
+ */
10
+ ignoreNonZeroExitCode: boolean;
11
+ }
12
+ export declare function sh<E extends Environments>(cmd: string, config?: Partial<SpawnConfig>): Value<E, Script<E>>;
13
+ export declare function script<E extends Environments>(path: string, config?: Partial<SpawnConfig>): Value<E, Script<E>>;
14
+ export {};
@@ -0,0 +1,46 @@
1
+ import { spawn } from "child_process";
2
+ import { resolve } from "path";
3
+ import { val } from "../orchestra/config";
4
+ const DEFAULT_SPAWN_CONFIG = {
5
+ waitForExit: true,
6
+ ignoreNonZeroExitCode: false,
7
+ };
8
+ function generateEnv(orchestra, place) {
9
+ return {
10
+ ...process.env,
11
+ ORCHESTRA_DIR: resolve("."),
12
+ RELEASE_NUMBER: orchestra.resolveConfig(orchestra.config.releaseNumber),
13
+ RELEASE_NAME: orchestra.resolveConfig(orchestra.config.releaseName),
14
+ PLACE_ID: place && orchestra.resolveConfig(place.placeId)?.toString(),
15
+ EXPERIENCE_ID: place && orchestra.resolveConfig(place.experienceId)?.toString(),
16
+ };
17
+ }
18
+ export function sh(cmd, config = {}) {
19
+ const fullConfig = {
20
+ ...DEFAULT_SPAWN_CONFIG,
21
+ ...config,
22
+ };
23
+ return val((orchestra, place, argv = []) => {
24
+ return new Promise((resolvePromise, reject) => {
25
+ const child = spawn(`${cmd}`, argv, {
26
+ cwd: place ? resolve(orchestra.resolveConfig(place.rootDir)) : undefined,
27
+ stdio: "inherit",
28
+ env: generateEnv(orchestra, place),
29
+ });
30
+ if (fullConfig.waitForExit) {
31
+ child.on("exit", (code) => {
32
+ if (code !== 0 && !fullConfig.ignoreNonZeroExitCode)
33
+ reject(code);
34
+ resolvePromise();
35
+ });
36
+ }
37
+ else {
38
+ resolvePromise();
39
+ }
40
+ });
41
+ });
42
+ }
43
+ export function script(path, config = {}) {
44
+ return sh(`${resolve(path)}`, config);
45
+ }
46
+ //# sourceMappingURL=script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script.js","sourceRoot":"","sources":["../../../src/helpers/script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAqC,GAAG,EAAS,MAAM,qBAAqB,CAAC;AAcpF,MAAM,oBAAoB,GAAgB;IACzC,WAAW,EAAE,IAAI;IACjB,qBAAqB,EAAE,KAAK;C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,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB;wBAAE,MAAM,CAAC,IAAI,CAAC,CAAC;oBAClE,cAAc,EAAE,CAAC;gBAClB,CAAC,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACP,cAAc,EAAE,CAAC;YAClB,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AACD,MAAM,UAAU,MAAM,CAAyB,IAAY,EAAE,SAA+B,EAAE;IAC7F,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./commands";
2
+ export * from "./orchestra";
3
+ export * from "./helpers/release";
4
+ export * from "./helpers/script";
@@ -0,0 +1,5 @@
1
+ export * from "./commands";
2
+ export * from "./orchestra";
3
+ export * from "./helpers/release";
4
+ export * from "./helpers/script";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const logger: import("consola").ConsolaInstance;
@@ -0,0 +1,3 @@
1
+ import { createConsola } from "consola";
2
+ export const logger = createConsola({});
3
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { Orchestra } from "./orchestra";
2
+ /**
3
+ * A value that is resolved using the Orchestra context
4
+ */
5
+ export type Value<E extends Environments, T> = (orchestra: Orchestra<E>) => T;
6
+ /**
7
+ * Allow either a raw value or a computed one
8
+ */
9
+ export type MaybeValue<E extends Environments, T> = T | Value<E, T>;
10
+ /**
11
+ * Resolve a MaybeValue at runtime
12
+ */
13
+ export declare function resolveValue<E extends Environments, T>(value: MaybeValue<E, T>, orchestra: Orchestra<E>): T;
14
+ /**
15
+ * Helper to wrap static values
16
+ */
17
+ export declare function val<E extends Environments, T>(value: T): Value<E, T>;
18
+ /**
19
+ * Environment-based value helper
20
+ */
21
+ export declare function env<V extends Record<string, unknown>>(values: V): <E extends { [K in keyof V]: EnvironmentConfig; }>(orchestra: Orchestra<E>) => V[keyof V];
22
+ export type Script<E extends Environments> = (orchestra: Orchestra<E>, place?: PlaceConfig<E>, argv?: string[]) => Promise<void> | void;
23
+ /**
24
+ * A configuration for a place managed by an Orchestra
25
+ */
26
+ export interface PlaceConfig<E extends Environments> {
27
+ rootDir: MaybeValue<E, string>;
28
+ placeId: MaybeValue<E, number>;
29
+ experienceId: MaybeValue<E, number>;
30
+ scripts: {
31
+ /**
32
+ * A callback that runs when this place is built by the Orchestra
33
+ */
34
+ [k: string]: MaybeValue<E, Script<E>>;
35
+ };
36
+ }
37
+ /**
38
+ * A configuration for a specific environment within an Orchestra
39
+ */
40
+ export interface EnvironmentConfig {
41
+ /**
42
+ * Whether to use this environment as the default if no other environments are chosen
43
+ */
44
+ default?: boolean;
45
+ /**
46
+ * The NODE_ENV value that will result in this environment being chosen
47
+ */
48
+ nodeEnv?: string;
49
+ }
50
+ /**
51
+ * A list of environments available to an Orchestra
52
+ */
53
+ export type Environments = {
54
+ [k: string]: EnvironmentConfig;
55
+ };
56
+ /**
57
+ * A configuration for an Orchestra
58
+ */
59
+ export interface OrchestraConfig<E extends Environments> {
60
+ /**
61
+ * Semantic version
62
+ */
63
+ releaseNumber: string;
64
+ /**
65
+ * Human-friendly release name
66
+ */
67
+ releaseName: string;
68
+ /**
69
+ * Available environments
70
+ */
71
+ environments: E;
72
+ scripts?: {
73
+ /**
74
+ * Callback that runs before any scripts are run
75
+ */
76
+ prepare?: MaybeValue<E, Script<E>>;
77
+ } & Record<string, MaybeValue<E, Script<E>>>;
78
+ /**
79
+ * Places in this experience
80
+ */
81
+ places: [PlaceConfig<E>, ...PlaceConfig<E>[]];
82
+ }
83
+ /**
84
+ * Create an Orchestra config
85
+ */
86
+ export declare function orchestraConfig<const E extends Environments>(experience: OrchestraConfig<E>): OrchestraConfig<E>;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Resolve a MaybeValue at runtime
3
+ */
4
+ export function resolveValue(value, orchestra) {
5
+ return typeof value === "function" ? value(orchestra) : value;
6
+ }
7
+ /**
8
+ * Helper to wrap static values
9
+ */
10
+ export function val(value) {
11
+ return () => value;
12
+ }
13
+ /**
14
+ * Environment-based value helper
15
+ */
16
+ export function env(values) {
17
+ return (orchestra) => {
18
+ return values[orchestra.environment];
19
+ };
20
+ }
21
+ /**
22
+ * Create an Orchestra config
23
+ */
24
+ export function orchestraConfig(experience) {
25
+ return experience;
26
+ }
27
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/orchestra/config.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,UAAU,YAAY,CAA4B,KAAuB,EAAE,SAAuB;IACvG,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAChF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAA4B,KAAQ;IACtD,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAoC,MAAS;IAC/D,OAAO,CAAkD,SAAuB,EAAc,EAAE;QAC/F,OAAO,MAAM,CAAC,SAAS,CAAC,WAAsB,CAAC,CAAC;IACjD,CAAC,CAAC;AACH,CAAC;AA8ED;;GAEG;AACH,MAAM,UAAU,eAAe,CAA+B,UAA8B;IAC3F,OAAO,UAAU,CAAC;AACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./config";
2
+ export * from "./orchestra";
@@ -0,0 +1,3 @@
1
+ export * from "./config";
2
+ export * from "./orchestra";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/orchestra/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Environments, MaybeValue, OrchestraConfig } from "./config";
2
+ export declare const ORCHESTRA_CONFIG_FILENAME = "orchestra.config.ts";
3
+ export declare class Orchestra<E extends Environments> {
4
+ readonly config: OrchestraConfig<E>;
5
+ static fromDirectory(directoryPath: string): Promise<Orchestra<never>>;
6
+ static fromFileConfig(filePath: string): Promise<Orchestra<never>>;
7
+ readonly environment: keyof E;
8
+ constructor(config: OrchestraConfig<E>);
9
+ runScripts(scriptName: string, argv?: string[]): Promise<void>;
10
+ resolveConfig<T>(config: MaybeValue<E, T>): T;
11
+ }
@@ -0,0 +1,45 @@
1
+ import assert from "assert";
2
+ import { createJiti } from "jiti";
3
+ import { resolve } from "path";
4
+ import { resolveValue } from "./config";
5
+ const jiti = createJiti(__filename);
6
+ export const ORCHESTRA_CONFIG_FILENAME = "orchestra.config.ts";
7
+ export class Orchestra {
8
+ config;
9
+ static async fromDirectory(directoryPath) {
10
+ return await Orchestra.fromFileConfig(resolve(directoryPath, ORCHESTRA_CONFIG_FILENAME));
11
+ }
12
+ static async fromFileConfig(filePath) {
13
+ const config = await jiti.import(resolve(filePath), {
14
+ default: true,
15
+ });
16
+ return new Orchestra(config);
17
+ }
18
+ environment;
19
+ constructor(config) {
20
+ this.config = config;
21
+ for (const [environmentName, environmentConfig] of Object.entries(config.environments)) {
22
+ if (this.environment)
23
+ continue;
24
+ const NODE_ENV = process.env.NODE_ENV ?? "unknown";
25
+ if (environmentConfig.default) {
26
+ this.environment = environmentName;
27
+ }
28
+ else if (NODE_ENV == environmentConfig.nodeEnv) {
29
+ this.environment = environmentName;
30
+ }
31
+ }
32
+ assert(this.environment, `Orchestra confiag is invalid, no default or otherwise valid environments provided`);
33
+ }
34
+ async runScripts(scriptName, argv) {
35
+ await this.resolveConfig(this.config.scripts?.prepare)?.(this, undefined, argv);
36
+ await this.resolveConfig(this.config.scripts?.[scriptName])?.(this, undefined, argv);
37
+ for (const place of this.config.places) {
38
+ await this.resolveConfig(place.scripts[scriptName])?.(this, place, argv);
39
+ }
40
+ }
41
+ resolveConfig(config) {
42
+ return resolveValue(config, this);
43
+ }
44
+ }
45
+ //# sourceMappingURL=orchestra.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestra.js","sourceRoot":"","sources":["../../../src/orchestra/orchestra.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAA6C,YAAY,EAAE,MAAM,UAAU,CAAC;AAEnF,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAE/D,MAAM,OAAO,SAAS;IAeO;IAdrB,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,aAAqB;QACtD,OAAO,MAAM,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,yBAAyB,CAAC,CAAC,CAAC;IAC1F,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,QAAgB;QAClD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACnD,OAAO,EAAE,IAAI;SACb,CAAC,CAAC;Q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C;IAEM,aAAa,CAAI,MAAwB;QAC/C,OAAO,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;CACD"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "rbxts-orchestra",
3
+ "version": "0.1.0-dev.0",
4
+ "description": "A build orchestrator.",
5
+ "main": "src/index.ts",
6
+ "bin": {
7
+ "orchestra": "./bin/run"
8
+ },
9
+ "directories": {
10
+ "lib": "src",
11
+ "bin": "bin"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "bin/run"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsup-node && tsc",
19
+ "build:watch": "tsup-node --watch",
20
+ "clean": "rimraf dist",
21
+ "compile": "tsc",
22
+ "format": "prettier . --check",
23
+ "format:fix": "prettier . --write",
24
+ "lint": "eslint .",
25
+ "lint:fix": "eslint . --fix",
26
+ "start": "ts-node ./bin/run.ts",
27
+ "start:node": "node ./bin/run",
28
+ "prepublish": "npm run build"
29
+ },
30
+ "devDependencies": {
31
+ "@tsconfig/node20": "^20.1.4",
32
+ "@types/node": "^20.12.12",
33
+ "@types/yargs": "^17.0.32",
34
+ "eslint": "^9.39.2",
35
+ "eslint-config-prettier": "^10.1.8",
36
+ "eslint-plugin-import": "^2.32.0",
37
+ "eslint-plugin-prettier": "^5.5.4",
38
+ "eslint-plugin-unused-imports": "^4.3.0",
39
+ "prettier": "^3.7.4",
40
+ "rimraf": "^5.0.7",
41
+ "ts-node": "^10.9.2",
42
+ "tsup": "^8.0.2",
43
+ "typescript": "^5.5.3",
44
+ "typescript-eslint": "^8.51.0"
45
+ },
46
+ "dependencies": {
47
+ "consola": "^3.2.3",
48
+ "picocolors": "^1.0.1",
49
+ "yargs": "^17.7.2",
50
+ "jiti": "^2.6.1"
51
+ }
52
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./commands";
2
+ export * from "./orchestra";
3
+ export * from "./helpers/release";
4
+ export * from "./helpers/script";