@certik/skynet 0.22.2 → 0.22.3

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/app.js CHANGED
@@ -1,41 +1,3 @@
1
- // src/selector.ts
2
- function getSelectorDesc(selector) {
3
- return Object.keys(selector).map((name) => {
4
- return ` --${name.padEnd(14)}${selector[name].desc || selector[name].description || ""}`;
5
- }).join(`
6
- `);
7
- }
8
- function getSelectorFlags(selector) {
9
- return Object.keys(selector).reduce((acc, name) => {
10
- const flag = {
11
- type: selector[name].type || "string",
12
- ...selector[name]
13
- };
14
- if (!selector[name].optional && selector[name].isRequired !== false) {
15
- flag.isRequired = true;
16
- }
17
- return { ...acc, [name]: flag };
18
- }, {});
19
- }
20
- function toSelectorString(selectorFlags, delim = ",") {
21
- return Object.keys(selectorFlags).sort().map((flag) => {
22
- return `${flag}=${selectorFlags[flag]}`;
23
- }).join(delim);
24
- }
25
- function normalizeSelectorValue(v) {
26
- return v.replace(/[^A-Za-z0-9]+/g, "-");
27
- }
28
- function getJobName(name, selectorFlags, mode) {
29
- const selectorNamePart = Object.keys(selectorFlags).sort().map((name2) => selectorFlags[name2]).join("-");
30
- let jobName = name;
31
- if (mode) {
32
- jobName += `-${mode}`;
33
- }
34
- if (selectorNamePart.length > 0) {
35
- jobName += `-${normalizeSelectorValue(selectorNamePart)}`;
36
- }
37
- return jobName;
38
- }
39
1
  // src/env.ts
40
2
  function ensureAndGet(envName, defaultValue) {
41
3
  return process.env[envName] || defaultValue;
@@ -55,208 +17,56 @@ function isProduction() {
55
17
  function isDev() {
56
18
  return getEnvironment() === "dev";
57
19
  }
58
- // src/log.ts
59
- function isObject(a) {
60
- return !!a && a.constructor === Object;
61
- }
62
- function print(o) {
63
- if (Array.isArray(o)) {
64
- return `[${o.map(print).join(", ")}]`;
65
- }
66
- if (isObject(o)) {
67
- return `{${Object.keys(o).map((k) => `${k}: ${o[k]}`).join(", ")}}`;
20
+ // src/util.ts
21
+ function range(startAt, endAt, step) {
22
+ const arr = [];
23
+ for (let i = startAt;i <= endAt; i += step) {
24
+ arr.push([i, Math.min(endAt, i + step - 1)]);
68
25
  }
69
- return `${o}`;
26
+ return arr;
70
27
  }
71
- function getLine(params) {
72
- let line = "";
73
- for (let i = 0, l = params.length;i < l; i++) {
74
- line += `${print(params[i])} `.replace(/\n/gm, "\t");
28
+ function arrayGroup(array, groupSize) {
29
+ const groups = [];
30
+ for (let i = 0;i < array.length; i += groupSize) {
31
+ groups.push(array.slice(i, i + groupSize));
75
32
  }
76
- return line.trim();
77
- }
78
- function timestamp() {
79
- return new Date().toISOString();
33
+ return groups;
80
34
  }
81
- var inline = {
82
- debug: function(...args) {
83
- if (true) {
84
- console.log(`${timestamp()} ${getLine(args)}`);
85
- }
86
- },
87
- log: function(...args) {
88
- if (true) {
89
- console.log(`${timestamp()} ${getLine(args)}`);
90
- }
91
- },
92
- error: function(...args) {
93
- if (true) {
94
- console.error(`${timestamp()} ${getLine(args)}`);
95
- }
96
- }
97
- };
98
- var logger = {
99
- debug: function(...args) {
100
- if (true) {
101
- console.log(`[${timestamp()}]`, ...args);
102
- }
103
- },
104
- log: function(...args) {
105
- if (true) {
106
- console.log(`[${timestamp()}]`, ...args);
107
- }
108
- },
109
- error: function(...args) {
110
- if (true) {
111
- console.error(`[${timestamp()}]`, ...args);
112
- }
35
+ function fillRange(start, end) {
36
+ const result = [];
37
+ for (let i = start;i <= end; i++) {
38
+ result.push(i);
113
39
  }
114
- };
115
- // src/api.ts
116
- import osModule from "os";
117
- import express from "express";
118
- import meow from "meow";
119
- async function logStartMiddleware(_, res, next) {
120
- const start = new Date;
121
- res.set("x-requested-at", start.toISOString());
122
- next();
40
+ return result;
123
41
  }
124
- async function contextMiddleware(_, res, next) {
125
- res.set("x-instance-id", osModule.hostname());
126
- next();
42
+ // src/date.ts
43
+ var MS_IN_A_DAY = 3600 * 24 * 1000;
44
+ function getDateOnly(date) {
45
+ return new Date(date).toISOString().split("T")[0];
127
46
  }
128
- async function logEndMiddleware(req, res, next) {
129
- const requestedAt = res.get("x-requested-at");
130
- if (!requestedAt) {
131
- inline.log("missing x-requested-at header");
132
- next();
133
- return;
134
- }
135
- const start = new Date(requestedAt).getTime();
136
- const end = new Date().getTime();
137
- const logInfo = {
138
- start,
139
- end,
140
- elapsed: `${end - start}ms`,
141
- endpoint: req.path,
142
- host: req.hostname,
143
- status: res.statusCode
144
- };
145
- if (res.statusMessage) {
146
- logInfo.errorMessage = res.statusMessage;
147
- }
148
- inline.log(JSON.stringify(logInfo));
149
- next();
47
+ function findDateAfter(date, n) {
48
+ const d = new Date(date);
49
+ const after = new Date(d.getTime() + MS_IN_A_DAY * n);
50
+ return getDateOnly(after);
150
51
  }
151
- var apiKeyMiddleware = (key) => {
152
- async function requireAPIKey(req, res, next) {
153
- try {
154
- const apiKey = req.get("x-api-key") || req.query["api-key"];
155
- if (!apiKey) {
156
- inline.log("request without api key");
157
- res.status(400).send("require x-api-key header");
158
- return;
159
- }
160
- if (typeof key === "string") {
161
- if (apiKey !== key) {
162
- inline.log("request has an invalid api key");
163
- res.status(400).send("invalid api key");
164
- return;
165
- }
166
- inline.log(`requested by valid key ${key.slice(0, 6)}`);
167
- } else {
168
- const name = key[apiKey];
169
- if (!name) {
170
- inline.log("request has an invalid api key");
171
- res.status(400).send("invalid api key");
172
- return;
173
- }
174
- inline.log(`requested by authorized user ${name}`);
175
- }
176
- next();
177
- } catch (err) {
178
- inline.log("check api key error", err);
179
- res.status(500).send("internal error");
180
- }
181
- }
182
- return requireAPIKey;
183
- };
184
- async function startApiApp({
185
- binaryName,
186
- name,
187
- selector = {},
188
- routes,
189
- serve,
190
- beforeListen
191
- }) {
192
- const app = express();
193
- app.use(express.json({ limit: "20mb" }));
194
- const cli = meow(`
195
- Usage
196
- $ ${binaryName} <options>
197
-
198
- Options
199
- ${getSelectorDesc(selector)}
200
- --verbose Output debug messages
201
- `, {
202
- importMeta: import.meta,
203
- description: false,
204
- version: false,
205
- flags: {
206
- ...getSelectorFlags(selector),
207
- verbose: {
208
- type: "boolean",
209
- default: false
210
- }
211
- }
212
- });
213
- const { verbose, ...selectorFlags } = cli.flags;
214
- for (const route of routes) {
215
- const method = route.method ? route.method.toLowerCase() : "get";
216
- const middlewares = route.middlewares || [];
217
- if (route.protected) {
218
- if (!serve.apiKey) {
219
- throw new Error("serve.apiKey is required for protected route");
220
- }
221
- middlewares.unshift(apiKeyMiddleware(serve.apiKey));
222
- }
223
- if (app[method]) {
224
- if (verbose) {
225
- inline.log(`registering ${method} ${route.path}`);
226
- }
227
- app[method](route.path, contextMiddleware, logStartMiddleware, ...middlewares, async (req, res, next) => {
228
- try {
229
- await route.handler({ req, res, ...selectorFlags });
230
- } catch (routeErr) {
231
- if (routeErr instanceof Error) {
232
- inline.log("caught route err", routeErr, routeErr.stack);
233
- res.status(500).send(`internal server error: ${routeErr.message}`);
234
- } else {
235
- inline.log("caught route err", routeErr);
236
- res.status(500).send("internal server error");
237
- }
238
- }
239
- next();
240
- }, logEndMiddleware);
241
- }
242
- }
243
- if (!routes.some((r) => r.path === "/" && r.method?.toUpperCase() === "GET")) {
244
- app.get("/", (_, res) => {
245
- res.send("ok");
246
- });
52
+ function daysInRange(from, to) {
53
+ const fromTime = new Date(from).getTime();
54
+ const toTime = new Date(to).getTime();
55
+ if (fromTime > toTime) {
56
+ throw new Error(`range to date couldn't be earlier than range from date`);
247
57
  }
248
- if (beforeListen) {
249
- await beforeListen({ app });
58
+ const daysBetween = Math.floor((toTime - fromTime) / MS_IN_A_DAY);
59
+ const dates = [getDateOnly(new Date(fromTime))];
60
+ for (let i = 1;i <= daysBetween; i += 1) {
61
+ dates.push(getDateOnly(new Date(fromTime + i * MS_IN_A_DAY)));
250
62
  }
251
- app.listen(serve.port, () => {
252
- if (isProduction()) {
253
- inline.log(`${name} listening at https://api.wf.corp.certik.com${serve.prefix}`);
254
- } else {
255
- inline.log(`${name} listening at http://localhost:${serve.port}`);
256
- }
257
- });
63
+ return dates;
64
+ }
65
+ function dateRange(from, to, step) {
66
+ const days = daysInRange(from, to);
67
+ const windows = arrayGroup(days, step);
68
+ return windows.map((w) => [w[0], w[w.length - 1]]);
258
69
  }
259
-
260
70
  // src/object-hash.ts
261
71
  import xh from "@node-rs/xxhash";
262
72
  function getHash(obj) {
@@ -383,28 +193,63 @@ function memoize(func, options) {
383
193
  }
384
194
  return pMemoize(func, options);
385
195
  }
386
- // src/util.ts
387
- function range(startAt, endAt, step) {
388
- const arr = [];
389
- for (let i = startAt;i <= endAt; i += step) {
390
- arr.push([i, Math.min(endAt, i + step - 1)]);
196
+ // src/log.ts
197
+ function isObject(a) {
198
+ return !!a && a.constructor === Object;
199
+ }
200
+ function print(o) {
201
+ if (Array.isArray(o)) {
202
+ return `[${o.map(print).join(", ")}]`;
391
203
  }
392
- return arr;
204
+ if (isObject(o)) {
205
+ return `{${Object.keys(o).map((k) => `${k}: ${o[k]}`).join(", ")}}`;
206
+ }
207
+ return `${o}`;
393
208
  }
394
- function arrayGroup(array, groupSize) {
395
- const groups = [];
396
- for (let i = 0;i < array.length; i += groupSize) {
397
- groups.push(array.slice(i, i + groupSize));
209
+ function getLine(params) {
210
+ let line = "";
211
+ for (let i = 0, l = params.length;i < l; i++) {
212
+ line += `${print(params[i])} `.replace(/\n/gm, "\t");
213
+ }
214
+ return line.trim();
215
+ }
216
+ function timestamp() {
217
+ return new Date().toISOString();
218
+ }
219
+ var inline = {
220
+ debug: function(...args) {
221
+ if (true) {
222
+ console.log(`${timestamp()} ${getLine(args)}`);
223
+ }
224
+ },
225
+ log: function(...args) {
226
+ if (true) {
227
+ console.log(`${timestamp()} ${getLine(args)}`);
228
+ }
229
+ },
230
+ error: function(...args) {
231
+ if (true) {
232
+ console.error(`${timestamp()} ${getLine(args)}`);
233
+ }
398
234
  }
399
- return groups;
400
- }
401
- function fillRange(start, end) {
402
- const result = [];
403
- for (let i = start;i <= end; i++) {
404
- result.push(i);
235
+ };
236
+ var logger = {
237
+ debug: function(...args) {
238
+ if (true) {
239
+ console.log(`[${timestamp()}]`, ...args);
240
+ }
241
+ },
242
+ log: function(...args) {
243
+ if (true) {
244
+ console.log(`[${timestamp()}]`, ...args);
245
+ }
246
+ },
247
+ error: function(...args) {
248
+ if (true) {
249
+ console.error(`[${timestamp()}]`, ...args);
250
+ }
405
251
  }
406
- return result;
407
- }
252
+ };
408
253
  // src/dynamodb.ts
409
254
  import {
410
255
  DynamoDBDocumentClient,
@@ -719,6 +564,44 @@ async function deleteRecordsByHashKey(tableName, indexName, hashKeyValue, verbos
719
564
  }
720
565
  return totalDeleted;
721
566
  }
567
+ // src/selector.ts
568
+ function getSelectorDesc(selector) {
569
+ return Object.keys(selector).map((name) => {
570
+ return ` --${name.padEnd(14)}${selector[name].desc || selector[name].description || ""}`;
571
+ }).join(`
572
+ `);
573
+ }
574
+ function getSelectorFlags(selector) {
575
+ return Object.keys(selector).reduce((acc, name) => {
576
+ const flag = {
577
+ type: selector[name].type || "string",
578
+ ...selector[name]
579
+ };
580
+ if (!selector[name].optional && selector[name].isRequired !== false) {
581
+ flag.isRequired = true;
582
+ }
583
+ return { ...acc, [name]: flag };
584
+ }, {});
585
+ }
586
+ function toSelectorString(selectorFlags, delim = ",") {
587
+ return Object.keys(selectorFlags).sort().map((flag) => {
588
+ return `${flag}=${selectorFlags[flag]}`;
589
+ }).join(delim);
590
+ }
591
+ function normalizeSelectorValue(v) {
592
+ return v.replace(/[^A-Za-z0-9]+/g, "-");
593
+ }
594
+ function getJobName(name, selectorFlags, mode) {
595
+ const selectorNamePart = Object.keys(selectorFlags).sort().map((name2) => selectorFlags[name2]).join("-");
596
+ let jobName = name;
597
+ if (mode) {
598
+ jobName += `-${mode}`;
599
+ }
600
+ if (selectorNamePart.length > 0) {
601
+ jobName += `-${normalizeSelectorValue(selectorNamePart)}`;
602
+ }
603
+ return jobName;
604
+ }
722
605
  // src/cli.ts
723
606
  import path from "path";
724
607
  import fs from "fs";
@@ -754,36 +637,8 @@ function detectBin() {
754
637
  const wd = detectDirectory(process.argv[1], "package.json");
755
638
  return process.argv[1].slice(wd.length + path.sep.length).replace(path.sep, "/");
756
639
  }
757
- // src/date.ts
758
- var MS_IN_A_DAY = 3600 * 24 * 1000;
759
- function getDateOnly(date) {
760
- return new Date(date).toISOString().split("T")[0];
761
- }
762
- function findDateAfter(date, n) {
763
- const d = new Date(date);
764
- const after = new Date(d.getTime() + MS_IN_A_DAY * n);
765
- return getDateOnly(after);
766
- }
767
- function daysInRange(from, to) {
768
- const fromTime = new Date(from).getTime();
769
- const toTime = new Date(to).getTime();
770
- if (fromTime > toTime) {
771
- throw new Error(`range to date couldn't be earlier than range from date`);
772
- }
773
- const daysBetween = Math.floor((toTime - fromTime) / MS_IN_A_DAY);
774
- const dates = [getDateOnly(new Date(fromTime))];
775
- for (let i = 1;i <= daysBetween; i += 1) {
776
- dates.push(getDateOnly(new Date(fromTime + i * MS_IN_A_DAY)));
777
- }
778
- return dates;
779
- }
780
- function dateRange(from, to, step) {
781
- const days = daysInRange(from, to);
782
- const windows = arrayGroup(days, step);
783
- return windows.map((w) => [w[0], w[w.length - 1]]);
784
- }
785
640
  // src/indexer.ts
786
- import meow2 from "meow";
641
+ import meow from "meow";
787
642
  var STATE_TABLE_NAME = "skynet-" + getEnvironment() + "-indexer-state";
788
643
  async function getIndexerLatestId(name, selectorFlags) {
789
644
  const record = await getRecordByKey(STATE_TABLE_NAME, {
@@ -1126,7 +981,7 @@ function createModeIndexerApp({
1126
981
  if (!binaryName) {
1127
982
  binaryName = getBinaryName();
1128
983
  }
1129
- const cli = meow2(`
984
+ const cli = meow(`
1130
985
  Usage
1131
986
 
1132
987
  $ ${binaryName} <options>
@@ -1185,7 +1040,7 @@ function createIndexerApp({
1185
1040
  if (!binaryName) {
1186
1041
  binaryName = getBinaryName();
1187
1042
  }
1188
- const cli = meow2(`
1043
+ const cli = meow(`
1189
1044
  Usage
1190
1045
  $ ${binaryName} <options>
1191
1046
 
@@ -1243,7 +1098,7 @@ ${selector ? getSelectorDesc(selector) : ""}
1243
1098
  import fs2 from "fs/promises";
1244
1099
  import fso from "fs";
1245
1100
  import { execa } from "execa";
1246
- import meow3 from "meow";
1101
+ import meow2 from "meow";
1247
1102
  import chalk from "chalk";
1248
1103
  import which from "which";
1249
1104
  var INTERVAL_ALIASES = {
@@ -1550,7 +1405,7 @@ function createModeDeploy({
1550
1405
  if (!binaryName) {
1551
1406
  binaryName = getBinaryName();
1552
1407
  }
1553
- const cli = meow3(`
1408
+ const cli = meow2(`
1554
1409
  Usage
1555
1410
 
1556
1411
  $ ${binaryName} <options>
@@ -1681,7 +1536,7 @@ function createDeploy({
1681
1536
  if (!binaryName) {
1682
1537
  binaryName = getBinaryName();
1683
1538
  }
1684
- const cli = meow3(`
1539
+ const cli = meow2(`
1685
1540
  Usage
1686
1541
 
1687
1542
  $ ${binaryName} <options>
@@ -1730,6 +1585,151 @@ ${getSelectorDesc(selector)}
1730
1585
  }
1731
1586
  return { deploy };
1732
1587
  }
1588
+ // src/api.ts
1589
+ import osModule from "os";
1590
+ import express from "express";
1591
+ import meow3 from "meow";
1592
+ async function logStartMiddleware(_, res, next) {
1593
+ const start = new Date;
1594
+ res.set("x-requested-at", start.toISOString());
1595
+ next();
1596
+ }
1597
+ async function contextMiddleware(_, res, next) {
1598
+ res.set("x-instance-id", osModule.hostname());
1599
+ next();
1600
+ }
1601
+ async function logEndMiddleware(req, res, next) {
1602
+ const requestedAt = res.get("x-requested-at");
1603
+ if (!requestedAt) {
1604
+ inline.log("missing x-requested-at header");
1605
+ next();
1606
+ return;
1607
+ }
1608
+ const start = new Date(requestedAt).getTime();
1609
+ const end = new Date().getTime();
1610
+ const logInfo = {
1611
+ start,
1612
+ end,
1613
+ elapsed: `${end - start}ms`,
1614
+ endpoint: req.path,
1615
+ host: req.hostname,
1616
+ status: res.statusCode
1617
+ };
1618
+ if (res.statusMessage) {
1619
+ logInfo.errorMessage = res.statusMessage;
1620
+ }
1621
+ inline.log(JSON.stringify(logInfo));
1622
+ next();
1623
+ }
1624
+ var apiKeyMiddleware = (key) => {
1625
+ async function requireAPIKey(req, res, next) {
1626
+ try {
1627
+ const apiKey = req.get("x-api-key") || req.query["api-key"];
1628
+ if (!apiKey) {
1629
+ inline.log("request without api key");
1630
+ res.status(400).send("require x-api-key header");
1631
+ return;
1632
+ }
1633
+ if (typeof key === "string") {
1634
+ if (apiKey !== key) {
1635
+ inline.log("request has an invalid api key");
1636
+ res.status(400).send("invalid api key");
1637
+ return;
1638
+ }
1639
+ inline.log(`requested by valid key ${key.slice(0, 6)}`);
1640
+ } else {
1641
+ const name = key[apiKey];
1642
+ if (!name) {
1643
+ inline.log("request has an invalid api key");
1644
+ res.status(400).send("invalid api key");
1645
+ return;
1646
+ }
1647
+ inline.log(`requested by authorized user ${name}`);
1648
+ }
1649
+ next();
1650
+ } catch (err) {
1651
+ inline.log("check api key error", err);
1652
+ res.status(500).send("internal error");
1653
+ }
1654
+ }
1655
+ return requireAPIKey;
1656
+ };
1657
+ async function startApiApp({
1658
+ binaryName,
1659
+ name,
1660
+ selector = {},
1661
+ routes,
1662
+ serve,
1663
+ beforeListen
1664
+ }) {
1665
+ const app = express();
1666
+ app.use(express.json({ limit: "20mb" }));
1667
+ const cli = meow3(`
1668
+ Usage
1669
+ $ ${binaryName} <options>
1670
+
1671
+ Options
1672
+ ${getSelectorDesc(selector)}
1673
+ --verbose Output debug messages
1674
+ `, {
1675
+ importMeta: import.meta,
1676
+ description: false,
1677
+ version: false,
1678
+ flags: {
1679
+ ...getSelectorFlags(selector),
1680
+ verbose: {
1681
+ type: "boolean",
1682
+ default: false
1683
+ }
1684
+ }
1685
+ });
1686
+ const { verbose, ...selectorFlags } = cli.flags;
1687
+ for (const route of routes) {
1688
+ const method = route.method ? route.method.toLowerCase() : "get";
1689
+ const middlewares = route.middlewares || [];
1690
+ if (route.protected) {
1691
+ if (!serve.apiKey) {
1692
+ throw new Error("serve.apiKey is required for protected route");
1693
+ }
1694
+ middlewares.unshift(apiKeyMiddleware(serve.apiKey));
1695
+ }
1696
+ if (app[method]) {
1697
+ if (verbose) {
1698
+ inline.log(`registering ${method} ${route.path}`);
1699
+ }
1700
+ app[method](route.path, contextMiddleware, logStartMiddleware, ...middlewares, async (req, res, next) => {
1701
+ try {
1702
+ await route.handler({ req, res, ...selectorFlags });
1703
+ } catch (routeErr) {
1704
+ if (routeErr instanceof Error) {
1705
+ inline.log("caught route err", routeErr, routeErr.stack);
1706
+ res.status(500).send(`internal server error: ${routeErr.message}`);
1707
+ } else {
1708
+ inline.log("caught route err", routeErr);
1709
+ res.status(500).send("internal server error");
1710
+ }
1711
+ }
1712
+ next();
1713
+ }, logEndMiddleware);
1714
+ }
1715
+ }
1716
+ if (!routes.some((r) => r.path === "/" && r.method?.toUpperCase() === "GET")) {
1717
+ app.get("/", (_, res) => {
1718
+ res.send("ok");
1719
+ });
1720
+ }
1721
+ if (beforeListen) {
1722
+ await beforeListen({ app });
1723
+ }
1724
+ app.listen(serve.port, () => {
1725
+ if (isProduction()) {
1726
+ inline.log(`${name} listening at https://api.wf.corp.certik.com${serve.prefix}`);
1727
+ } else {
1728
+ inline.log(`${name} listening at http://localhost:${serve.port}`);
1729
+ }
1730
+ });
1731
+ }
1732
+
1733
1733
  // src/app.ts
1734
1734
  import { EOL } from "os";
1735
1735
  function printAppHelp() {
package/dist/deploy.js CHANGED
@@ -1,3 +1,22 @@
1
+ // src/env.ts
2
+ function ensureAndGet(envName, defaultValue) {
3
+ return process.env[envName] || defaultValue;
4
+ }
5
+ function getEnvironment() {
6
+ return ensureAndGet("SKYNET_ENVIRONMENT", "dev");
7
+ }
8
+ function getEnvOrThrow(envName) {
9
+ if (!process.env[envName]) {
10
+ throw new Error(`Must set environment variable ${envName}`);
11
+ }
12
+ return process.env[envName];
13
+ }
14
+ function isProduction() {
15
+ return getEnvironment() === "prd";
16
+ }
17
+ function isDev() {
18
+ return getEnvironment() === "dev";
19
+ }
1
20
  // src/selector.ts
2
21
  function getSelectorDesc(selector) {
3
22
  return Object.keys(selector).map((name) => {
@@ -36,25 +55,6 @@ function getJobName(name, selectorFlags, mode) {
36
55
  }
37
56
  return jobName;
38
57
  }
39
- // src/env.ts
40
- function ensureAndGet(envName, defaultValue) {
41
- return process.env[envName] || defaultValue;
42
- }
43
- function getEnvironment() {
44
- return ensureAndGet("SKYNET_ENVIRONMENT", "dev");
45
- }
46
- function getEnvOrThrow(envName) {
47
- if (!process.env[envName]) {
48
- throw new Error(`Must set environment variable ${envName}`);
49
- }
50
- return process.env[envName];
51
- }
52
- function isProduction() {
53
- return getEnvironment() === "prd";
54
- }
55
- function isDev() {
56
- return getEnvironment() === "dev";
57
- }
58
58
  // src/cli.ts
59
59
  import path from "path";
60
60
  import fs from "fs";