@uniformdev/cli 20.72.3-alpha.14 → 20.72.3-alpha.23
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-MW3VQ4QM.mjs → chunk-Z4H2GIQQ.mjs} +1 -1
- package/dist/defaultConfig.mjs +1 -1
- package/dist/index.mjs +206 -92
- package/package.json +10 -10
|
@@ -21,7 +21,7 @@ import { dirname, extname, isAbsolute, resolve, sep } from "path";
|
|
|
21
21
|
// package.json
|
|
22
22
|
var package_default = {
|
|
23
23
|
name: "@uniformdev/cli",
|
|
24
|
-
version: "20.
|
|
24
|
+
version: "20.73.0",
|
|
25
25
|
description: "Uniform command line interface tool",
|
|
26
26
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
27
27
|
main: "./cli.js",
|
package/dist/defaultConfig.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
withFormatOptions,
|
|
24
24
|
withProjectOptions,
|
|
25
25
|
withTeamOptions
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-Z4H2GIQQ.mjs";
|
|
27
27
|
|
|
28
28
|
// src/index.ts
|
|
29
29
|
import * as dotenv from "dotenv";
|
|
@@ -497,7 +497,7 @@ var makeSpinner = () => {
|
|
|
497
497
|
const spin = async (text) => {
|
|
498
498
|
const spinner = ora(text).start();
|
|
499
499
|
spinners.push(spinner);
|
|
500
|
-
const minWait = new Promise((
|
|
500
|
+
const minWait = new Promise((resolve6) => setTimeout(resolve6, 500));
|
|
501
501
|
return async () => {
|
|
502
502
|
await minWait;
|
|
503
503
|
spinner.stop();
|
|
@@ -2158,53 +2158,134 @@ import yargs4 from "yargs";
|
|
|
2158
2158
|
|
|
2159
2159
|
// src/commands/automation/delete.ts
|
|
2160
2160
|
import { AutomationsClient } from "@uniformdev/automations-sdk/api";
|
|
2161
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
2162
|
+
import { resolve as resolve4 } from "path";
|
|
2163
|
+
|
|
2164
|
+
// src/cliLimitPolicy.ts
|
|
2165
|
+
import { createLimitPolicy } from "@uniformdev/canvas";
|
|
2166
|
+
var limit = process.env.UNIFORM_CLI_CONCURRENCY_LIMIT ? parseInt(process.env.UNIFORM_CLI_CONCURRENCY_LIMIT) : 10;
|
|
2167
|
+
var cliLimitPolicy = createLimitPolicy({
|
|
2168
|
+
throttle: { interval: 1e3, limit: 10 },
|
|
2169
|
+
retry: { retries: 3, factor: 2 },
|
|
2170
|
+
limit
|
|
2171
|
+
});
|
|
2172
|
+
|
|
2173
|
+
// src/commands/automation/resolveAutomationEntryFiles.ts
|
|
2174
|
+
import { existsSync as existsSync4, readdirSync, statSync } from "fs";
|
|
2175
|
+
import { join as join6, resolve as resolve2 } from "path";
|
|
2176
|
+
|
|
2177
|
+
// src/commands/automation/automationFilePattern.ts
|
|
2178
|
+
var AUTOMATION_EXTENSIONS = ["ts", "js", "mjs", "cjs"];
|
|
2179
|
+
var AUTOMATION_FILE_RE = new RegExp(`\\.automation\\.(${AUTOMATION_EXTENSIONS.join("|")})$`, "i");
|
|
2180
|
+
|
|
2181
|
+
// src/commands/automation/resolveAutomationEntryFiles.ts
|
|
2182
|
+
function resolveAutomationEntryFiles(paths) {
|
|
2183
|
+
const files = /* @__PURE__ */ new Set();
|
|
2184
|
+
for (const inputPath of paths) {
|
|
2185
|
+
const absPath = resolve2(inputPath);
|
|
2186
|
+
if (!existsSync4(absPath)) {
|
|
2187
|
+
throw new Error(`Path not found: "${inputPath}".`);
|
|
2188
|
+
}
|
|
2189
|
+
if (statSync(absPath).isDirectory()) {
|
|
2190
|
+
const matches = readdirSync(absPath).filter((name) => AUTOMATION_FILE_RE.test(name)).map((name) => join6(absPath, name)).filter((file) => statSync(file).isFile()).sort();
|
|
2191
|
+
if (matches.length === 0) {
|
|
2192
|
+
throw new Error(`No automation files (*.automation.ts) found in directory "${inputPath}".`);
|
|
2193
|
+
}
|
|
2194
|
+
for (const match of matches) {
|
|
2195
|
+
files.add(match);
|
|
2196
|
+
}
|
|
2197
|
+
} else {
|
|
2198
|
+
files.add(absPath);
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
return [...files];
|
|
2202
|
+
}
|
|
2161
2203
|
|
|
2162
2204
|
// src/commands/automation/resolveAutomationPublicId.ts
|
|
2163
|
-
import { existsSync as
|
|
2164
|
-
import { basename, extname as extname2, resolve as
|
|
2205
|
+
import { existsSync as existsSync5 } from "fs";
|
|
2206
|
+
import { basename, extname as extname2, resolve as resolve3 } from "path";
|
|
2165
2207
|
function resolveAutomationPublicId(identifier) {
|
|
2166
|
-
const absPath =
|
|
2167
|
-
if (
|
|
2168
|
-
return
|
|
2208
|
+
const absPath = resolve3(identifier);
|
|
2209
|
+
if (!existsSync5(absPath)) {
|
|
2210
|
+
return identifier;
|
|
2169
2211
|
}
|
|
2170
|
-
|
|
2212
|
+
const base = basename(absPath);
|
|
2213
|
+
const withoutAutomationSuffix = base.replace(AUTOMATION_FILE_RE, "");
|
|
2214
|
+
return withoutAutomationSuffix !== base ? withoutAutomationSuffix : basename(base, extname2(base));
|
|
2171
2215
|
}
|
|
2172
2216
|
|
|
2173
2217
|
// src/commands/automation/delete.ts
|
|
2218
|
+
function resolveDeleteTargets(identifiers) {
|
|
2219
|
+
const publicIds = /* @__PURE__ */ new Set();
|
|
2220
|
+
for (const identifier of identifiers) {
|
|
2221
|
+
const absPath = resolve4(identifier);
|
|
2222
|
+
if (existsSync6(absPath) && statSync2(absPath).isDirectory()) {
|
|
2223
|
+
for (const file of resolveAutomationEntryFiles([identifier])) {
|
|
2224
|
+
publicIds.add(resolveAutomationPublicId(file));
|
|
2225
|
+
}
|
|
2226
|
+
} else {
|
|
2227
|
+
publicIds.add(resolveAutomationPublicId(identifier));
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
return [...publicIds];
|
|
2231
|
+
}
|
|
2174
2232
|
var AutomationDeleteModule = {
|
|
2175
|
-
command: "delete <
|
|
2176
|
-
describe: "Deletes
|
|
2233
|
+
command: "delete <identifiers..>",
|
|
2234
|
+
describe: "Deletes one or more automations from a project.",
|
|
2177
2235
|
builder: (yargs44) => withConfiguration(
|
|
2178
2236
|
withApiOptions(
|
|
2179
2237
|
withProjectOptions(
|
|
2180
|
-
yargs44.positional("
|
|
2181
|
-
|
|
2238
|
+
yargs44.positional("identifiers", {
|
|
2239
|
+
array: true,
|
|
2182
2240
|
type: "string",
|
|
2183
|
-
|
|
2241
|
+
demandOption: true,
|
|
2242
|
+
describe: "One or more automation public IDs, local source files, and/or directories (same convention as deploy)."
|
|
2184
2243
|
})
|
|
2185
2244
|
)
|
|
2186
2245
|
)
|
|
2187
2246
|
),
|
|
2188
|
-
handler: async ({ apiHost, apiKey, proxy,
|
|
2247
|
+
handler: async ({ apiHost, apiKey, proxy, identifiers, project: projectId }) => {
|
|
2189
2248
|
const fetch2 = nodeFetchProxy(proxy);
|
|
2190
|
-
const client = new AutomationsClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
2191
|
-
|
|
2249
|
+
const client = new AutomationsClient({ apiKey, apiHost, fetch: fetch2, projectId, limitPolicy: cliLimitPolicy });
|
|
2250
|
+
let publicIds;
|
|
2192
2251
|
try {
|
|
2193
|
-
|
|
2194
|
-
console.log(`\u{1F5D1}\uFE0F Deleted automation "${publicId}".`);
|
|
2252
|
+
publicIds = resolveDeleteTargets(identifiers);
|
|
2195
2253
|
} catch (error) {
|
|
2196
2254
|
exitOnCliError(error);
|
|
2197
2255
|
}
|
|
2256
|
+
const results = await Promise.all(
|
|
2257
|
+
publicIds.map(async (publicId) => {
|
|
2258
|
+
try {
|
|
2259
|
+
await client.remove(publicId);
|
|
2260
|
+
console.log(`\u{1F5D1}\uFE0F Deleted automation "${publicId}".`);
|
|
2261
|
+
return true;
|
|
2262
|
+
} catch (error) {
|
|
2263
|
+
console.error(
|
|
2264
|
+
`\u274C Failed to delete "${publicId}": ${error instanceof Error ? error.message : String(error)}`
|
|
2265
|
+
);
|
|
2266
|
+
return false;
|
|
2267
|
+
}
|
|
2268
|
+
})
|
|
2269
|
+
);
|
|
2270
|
+
const failureCount = results.filter((succeeded) => !succeeded).length;
|
|
2271
|
+
if (publicIds.length > 1) {
|
|
2272
|
+
console.log(`
|
|
2273
|
+
Deleted ${publicIds.length - failureCount}/${publicIds.length} automations.`);
|
|
2274
|
+
}
|
|
2275
|
+
if (failureCount > 0) {
|
|
2276
|
+
process.exit(1);
|
|
2277
|
+
}
|
|
2198
2278
|
}
|
|
2199
2279
|
};
|
|
2200
2280
|
|
|
2201
2281
|
// src/commands/automation/deploy.ts
|
|
2202
2282
|
import { AutomationsClient as AutomationsClient2, formatAutomationWebhookUrl } from "@uniformdev/automations-sdk/api";
|
|
2283
|
+
import { relative } from "path";
|
|
2203
2284
|
|
|
2204
2285
|
// src/commands/automation/bundleAutomationForDeploy.ts
|
|
2205
2286
|
import { mkdtempSync, readFileSync as readFileSync2, rmSync } from "fs";
|
|
2206
2287
|
import { tmpdir } from "os";
|
|
2207
|
-
import { basename as basename2, join as
|
|
2288
|
+
import { basename as basename2, join as join7, resolve as resolve5 } from "path";
|
|
2208
2289
|
import { pathToFileURL } from "url";
|
|
2209
2290
|
|
|
2210
2291
|
// src/commands/bundleWorkerCode.ts
|
|
@@ -2297,21 +2378,23 @@ async function readAutomationMetadataFromBundle(bundlePath, publicId) {
|
|
|
2297
2378
|
throw new Error("Default export must be the return value of defineAutomation");
|
|
2298
2379
|
}
|
|
2299
2380
|
const metadata = automation.metadata;
|
|
2300
|
-
const
|
|
2381
|
+
const triggers = metadata.triggers.map(
|
|
2382
|
+
(trigger) => trigger.type === "aiTool" ? { type: "aiTool", inputSchema: toInputJsonSchema(metadata.inputSchema) } : trigger
|
|
2383
|
+
);
|
|
2301
2384
|
return {
|
|
2302
2385
|
publicId,
|
|
2303
2386
|
name: metadata.name,
|
|
2304
2387
|
description: metadata.description,
|
|
2305
|
-
|
|
2388
|
+
triggers,
|
|
2306
2389
|
compatibilityDate: metadata.compatibilityDate,
|
|
2307
2390
|
permissions: metadata.permissions
|
|
2308
2391
|
};
|
|
2309
2392
|
}
|
|
2310
2393
|
async function bundleAutomationForDeploy(entryFile) {
|
|
2311
|
-
const absEntry =
|
|
2394
|
+
const absEntry = resolve5(entryFile);
|
|
2312
2395
|
const publicId = resolveAutomationPublicId(absEntry);
|
|
2313
|
-
const workDir = mkdtempSync(
|
|
2314
|
-
const bundlePath =
|
|
2396
|
+
const workDir = mkdtempSync(join7(tmpdir(), "uniform-automation-deploy-"));
|
|
2397
|
+
const bundlePath = join7(workDir, "automation.mjs");
|
|
2315
2398
|
try {
|
|
2316
2399
|
await bundleWorkerCodeToFile(absEntry, bundlePath);
|
|
2317
2400
|
const metadata = await readAutomationMetadataFromBundle(bundlePath, publicId);
|
|
@@ -2331,46 +2414,88 @@ async function bundleAutomationForDeploy(entryFile) {
|
|
|
2331
2414
|
}
|
|
2332
2415
|
|
|
2333
2416
|
// src/commands/automation/deploy.ts
|
|
2417
|
+
function assertUniquePublicIds(files) {
|
|
2418
|
+
const byPublicId = /* @__PURE__ */ new Map();
|
|
2419
|
+
for (const file of files) {
|
|
2420
|
+
const publicId = resolveAutomationPublicId(file);
|
|
2421
|
+
const existing = byPublicId.get(publicId);
|
|
2422
|
+
if (existing) {
|
|
2423
|
+
throw new Error(
|
|
2424
|
+
`Multiple files resolve to the same automation public ID "${publicId}": ${relative(
|
|
2425
|
+
process.cwd(),
|
|
2426
|
+
existing
|
|
2427
|
+
)} and ${relative(process.cwd(), file)}.`
|
|
2428
|
+
);
|
|
2429
|
+
}
|
|
2430
|
+
byPublicId.set(publicId, file);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2334
2433
|
var AutomationDeployModule = {
|
|
2335
|
-
command: "deploy <
|
|
2336
|
-
describe: "Deploys
|
|
2434
|
+
command: "deploy <paths..>",
|
|
2435
|
+
describe: "Deploys one or more automations to a project.",
|
|
2337
2436
|
builder: (yargs44) => withConfiguration(
|
|
2338
2437
|
withApiOptions(
|
|
2339
2438
|
withProjectOptions(
|
|
2340
|
-
yargs44.positional("
|
|
2439
|
+
yargs44.positional("paths", {
|
|
2440
|
+
array: true,
|
|
2441
|
+
type: "string",
|
|
2341
2442
|
demandOption: true,
|
|
2342
|
-
describe: "
|
|
2443
|
+
describe: "One or more automation source files and/or directories. Each module must default-export the return value of defineAutomation. A directory is scanned (non-recursively) for files matching `*.automation.ts`."
|
|
2343
2444
|
}).option("compatibilityDate", {
|
|
2344
2445
|
type: "string",
|
|
2345
|
-
describe: "Overrides the compatibility date in metadata. Format: YYYY-MM-DD."
|
|
2446
|
+
describe: "Overrides the compatibility date in metadata for every deployed automation. Format: YYYY-MM-DD."
|
|
2346
2447
|
})
|
|
2347
2448
|
)
|
|
2348
2449
|
)
|
|
2349
2450
|
),
|
|
2350
|
-
handler: async ({ apiHost, apiKey, proxy,
|
|
2451
|
+
handler: async ({ apiHost, apiKey, proxy, paths, project: projectId, compatibilityDate }) => {
|
|
2351
2452
|
const fetch2 = nodeFetchProxy(proxy);
|
|
2352
|
-
const client = new AutomationsClient2({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
2353
|
-
let
|
|
2453
|
+
const client = new AutomationsClient2({ apiKey, apiHost, fetch: fetch2, projectId, limitPolicy: cliLimitPolicy });
|
|
2454
|
+
let files;
|
|
2354
2455
|
try {
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
await client.deploy({
|
|
2358
|
-
...bundled.metadata,
|
|
2359
|
-
code: bundled.code,
|
|
2360
|
-
compatibilityDate: compatibilityDate ?? bundled.metadata.compatibilityDate
|
|
2361
|
-
});
|
|
2362
|
-
console.log(
|
|
2363
|
-
`\u2705 Deployed automation "${bundled.metadata.publicId}" (${bundled.metadata.trigger.type}).`
|
|
2364
|
-
);
|
|
2365
|
-
if (bundled.metadata.trigger.type === "incomingWebhook") {
|
|
2366
|
-
console.log(
|
|
2367
|
-
`Webhook URL: ${formatAutomationWebhookUrl(apiHost, projectId, bundled.metadata.publicId)}`
|
|
2368
|
-
);
|
|
2369
|
-
}
|
|
2456
|
+
files = resolveAutomationEntryFiles(paths);
|
|
2457
|
+
assertUniquePublicIds(files);
|
|
2370
2458
|
} catch (error) {
|
|
2371
2459
|
exitOnCliError(error);
|
|
2372
|
-
}
|
|
2373
|
-
|
|
2460
|
+
}
|
|
2461
|
+
const results = await Promise.all(
|
|
2462
|
+
files.map(async (file) => {
|
|
2463
|
+
let cleanup;
|
|
2464
|
+
try {
|
|
2465
|
+
const bundled = await bundleAutomationForDeploy(file);
|
|
2466
|
+
cleanup = bundled.cleanup;
|
|
2467
|
+
await client.deploy({
|
|
2468
|
+
...bundled.metadata,
|
|
2469
|
+
code: bundled.code,
|
|
2470
|
+
compatibilityDate: compatibilityDate ?? bundled.metadata.compatibilityDate
|
|
2471
|
+
});
|
|
2472
|
+
const triggerKinds = bundled.metadata.triggers.map((trigger) => trigger.type);
|
|
2473
|
+
console.log(
|
|
2474
|
+
`\u2705 Deployed automation "${bundled.metadata.publicId}" (${triggerKinds.length} trigger${triggerKinds.length === 1 ? "" : "s"}: ${triggerKinds.join(", ")}).`
|
|
2475
|
+
);
|
|
2476
|
+
if (triggerKinds.includes("incomingWebhook")) {
|
|
2477
|
+
console.log(
|
|
2478
|
+
`Webhook URL: ${formatAutomationWebhookUrl(apiHost, projectId, bundled.metadata.publicId)}`
|
|
2479
|
+
);
|
|
2480
|
+
}
|
|
2481
|
+
return true;
|
|
2482
|
+
} catch (error) {
|
|
2483
|
+
console.error(
|
|
2484
|
+
`\u274C Failed to deploy "${relative(process.cwd(), file)}": ${error instanceof Error ? error.message : String(error)}`
|
|
2485
|
+
);
|
|
2486
|
+
return false;
|
|
2487
|
+
} finally {
|
|
2488
|
+
cleanup?.();
|
|
2489
|
+
}
|
|
2490
|
+
})
|
|
2491
|
+
);
|
|
2492
|
+
const failureCount = results.filter((succeeded) => !succeeded).length;
|
|
2493
|
+
if (files.length > 1) {
|
|
2494
|
+
console.log(`
|
|
2495
|
+
Deployed ${files.length - failureCount}/${files.length} automations.`);
|
|
2496
|
+
}
|
|
2497
|
+
if (failureCount > 0) {
|
|
2498
|
+
process.exit(1);
|
|
2374
2499
|
}
|
|
2375
2500
|
}
|
|
2376
2501
|
};
|
|
@@ -2395,7 +2520,7 @@ var AutomationListModule = {
|
|
|
2395
2520
|
automations.map((automation) => ({
|
|
2396
2521
|
publicId: automation.publicId,
|
|
2397
2522
|
name: automation.name,
|
|
2398
|
-
|
|
2523
|
+
triggers: automation.triggers.map((trigger) => trigger.config.type).join(", "),
|
|
2399
2524
|
enabled: automation.enabled,
|
|
2400
2525
|
lastDeployedAt: automation.lastDeployedAt,
|
|
2401
2526
|
lastDeployedBy: automation.lastDeployedBy
|
|
@@ -2427,17 +2552,6 @@ import yargs5 from "yargs";
|
|
|
2427
2552
|
// src/commands/canvas/commands/asset/_util.ts
|
|
2428
2553
|
import { AssetClient } from "@uniformdev/assets";
|
|
2429
2554
|
import { FileClient } from "@uniformdev/files";
|
|
2430
|
-
|
|
2431
|
-
// src/cliLimitPolicy.ts
|
|
2432
|
-
import { createLimitPolicy } from "@uniformdev/canvas";
|
|
2433
|
-
var limit = process.env.UNIFORM_CLI_CONCURRENCY_LIMIT ? parseInt(process.env.UNIFORM_CLI_CONCURRENCY_LIMIT) : 10;
|
|
2434
|
-
var cliLimitPolicy = createLimitPolicy({
|
|
2435
|
-
throttle: { interval: 1e3, limit: 10 },
|
|
2436
|
-
retry: { retries: 3, factor: 2 },
|
|
2437
|
-
limit
|
|
2438
|
-
});
|
|
2439
|
-
|
|
2440
|
-
// src/commands/canvas/commands/asset/_util.ts
|
|
2441
2555
|
var selectAssetIdentifier = (e) => e.asset._id;
|
|
2442
2556
|
var selectAssetDisplayName = (e) => `${e.asset.fields?.title?.value ?? "Untitled"} (pid: ${selectAssetIdentifier(e)})`;
|
|
2443
2557
|
function getAssetClient(options) {
|
|
@@ -2488,10 +2602,10 @@ var AssetListModule = {
|
|
|
2488
2602
|
|
|
2489
2603
|
// src/files/deleteDownloadedFileByUrl.ts
|
|
2490
2604
|
import fsj from "fs-jetpack";
|
|
2491
|
-
import { join as
|
|
2605
|
+
import { join as join9 } from "path";
|
|
2492
2606
|
|
|
2493
2607
|
// src/files/urlToFileName.ts
|
|
2494
|
-
import { join as
|
|
2608
|
+
import { join as join8 } from "path";
|
|
2495
2609
|
import { dirname } from "path";
|
|
2496
2610
|
var FILES_DIRECTORY_NAME = "files";
|
|
2497
2611
|
var getFilesDirectory = (directory) => {
|
|
@@ -2500,7 +2614,7 @@ var getFilesDirectory = (directory) => {
|
|
|
2500
2614
|
// If we are syncing to a directory, we want to write all files into a
|
|
2501
2615
|
// top-lvl folder. That way any entities that contain files will sync to the
|
|
2502
2616
|
// same directory, so there is no duplication
|
|
2503
|
-
|
|
2617
|
+
join8(directory, "..")
|
|
2504
2618
|
);
|
|
2505
2619
|
};
|
|
2506
2620
|
var urlToHash = (url) => {
|
|
@@ -2536,7 +2650,7 @@ var hashToPartialPathname = (hash) => {
|
|
|
2536
2650
|
var deleteDownloadedFileByUrl = async (url, options) => {
|
|
2537
2651
|
const writeDirectory = getFilesDirectory(options.directory);
|
|
2538
2652
|
const fileName = urlToFileName(url);
|
|
2539
|
-
const fileToDelete =
|
|
2653
|
+
const fileToDelete = join9(writeDirectory, FILES_DIRECTORY_NAME, fileName);
|
|
2540
2654
|
try {
|
|
2541
2655
|
await fsj.removeAsync(fileToDelete);
|
|
2542
2656
|
} catch {
|
|
@@ -2556,12 +2670,12 @@ import {
|
|
|
2556
2670
|
import { isRichTextNodeType, isRichTextValue, walkRichTextTree } from "@uniformdev/richtext";
|
|
2557
2671
|
import fsj4 from "fs-jetpack";
|
|
2558
2672
|
import PQueue3 from "p-queue";
|
|
2559
|
-
import { join as
|
|
2673
|
+
import { join as join12 } from "path";
|
|
2560
2674
|
|
|
2561
2675
|
// src/files/downloadFile.ts
|
|
2562
2676
|
import { createWriteStream } from "fs";
|
|
2563
2677
|
import fsj2 from "fs-jetpack";
|
|
2564
|
-
import { dirname as dirname2, join as
|
|
2678
|
+
import { dirname as dirname2, join as join10 } from "path";
|
|
2565
2679
|
import { Readable } from "stream";
|
|
2566
2680
|
import { pipeline } from "stream/promises";
|
|
2567
2681
|
var downloadedFilePathCacheByDirectory = /* @__PURE__ */ new Map();
|
|
@@ -2609,9 +2723,9 @@ var downloadFile = async ({
|
|
|
2609
2723
|
directory
|
|
2610
2724
|
}) => {
|
|
2611
2725
|
const writeDirectory = getFilesDirectory(directory);
|
|
2612
|
-
const filesDirectory =
|
|
2726
|
+
const filesDirectory = join10(writeDirectory, FILES_DIRECTORY_NAME);
|
|
2613
2727
|
const fileName = urlToFileName(fileUrl.toString());
|
|
2614
|
-
const filePath =
|
|
2728
|
+
const filePath = join10(filesDirectory, fileName);
|
|
2615
2729
|
const fileAlreadyExists = await fsj2.existsAsync(filePath);
|
|
2616
2730
|
if (fileAlreadyExists) {
|
|
2617
2731
|
return { url: fileUrl };
|
|
@@ -2654,7 +2768,7 @@ import fsj3 from "fs-jetpack";
|
|
|
2654
2768
|
import { imageSizeFromFile } from "image-size/fromFile";
|
|
2655
2769
|
import normalizeNewline from "normalize-newline";
|
|
2656
2770
|
import PQueue2 from "p-queue";
|
|
2657
|
-
import { join as
|
|
2771
|
+
import { join as join11 } from "path";
|
|
2658
2772
|
var uploadQueueByKey = /* @__PURE__ */ new Map();
|
|
2659
2773
|
var fileUploadQueue = new PQueue2({ concurrency: 10 });
|
|
2660
2774
|
var uploadFile = async ({
|
|
@@ -2681,7 +2795,7 @@ var uploadFile = async ({
|
|
|
2681
2795
|
return { id: file.id, url: file.url };
|
|
2682
2796
|
}
|
|
2683
2797
|
const localFileName = urlToFileName(fileUrl);
|
|
2684
|
-
const expectedFilePath =
|
|
2798
|
+
const expectedFilePath = join11(writeDirectory, FILES_DIRECTORY_NAME, localFileName);
|
|
2685
2799
|
const fileInspect = await fsj3.inspectAsync(expectedFilePath);
|
|
2686
2800
|
if (fileInspect?.type !== "file") {
|
|
2687
2801
|
console.warn(
|
|
@@ -2763,7 +2877,7 @@ var uploadFile = async ({
|
|
|
2763
2877
|
}
|
|
2764
2878
|
const file2 = await fileClient.get({ id });
|
|
2765
2879
|
if (!file2 || file2.state !== FILE_READY_STATE || !file2.url) {
|
|
2766
|
-
await new Promise((
|
|
2880
|
+
await new Promise((resolve6) => setTimeout(resolve6, 1e3));
|
|
2767
2881
|
return checkForFile();
|
|
2768
2882
|
}
|
|
2769
2883
|
return file2.url;
|
|
@@ -3009,7 +3123,7 @@ var replaceRemoteUrlsWithLocalReferences = async ({
|
|
|
3009
3123
|
try {
|
|
3010
3124
|
const localFileName = urlToFileName(fileUrl);
|
|
3011
3125
|
const fileExistsLocally = await fsj4.existsAsync(
|
|
3012
|
-
|
|
3126
|
+
join12(writeDirectory, FILES_DIRECTORY_NAME, localFileName)
|
|
3013
3127
|
);
|
|
3014
3128
|
if (fileExistsLocally) {
|
|
3015
3129
|
return;
|
|
@@ -11560,7 +11674,7 @@ npm run dev
|
|
|
11560
11674
|
|
|
11561
11675
|
// src/commands/new/commands/new-mesh-integration.ts
|
|
11562
11676
|
import { input as input2 } from "@inquirer/prompts";
|
|
11563
|
-
import { existsSync as
|
|
11677
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readdirSync as readdirSync2, readFileSync as readFileSync6, writeFileSync as writeFileSync2 } from "fs";
|
|
11564
11678
|
import path7 from "path";
|
|
11565
11679
|
import slugify2 from "slugify";
|
|
11566
11680
|
async function newMeshIntegrationHandler({
|
|
@@ -11609,7 +11723,7 @@ async function newMeshIntegrationHandler({
|
|
|
11609
11723
|
});
|
|
11610
11724
|
let done = await spin("Registering integration to team...");
|
|
11611
11725
|
const pathToManifest = path7.resolve(targetDir, "mesh-manifest.json");
|
|
11612
|
-
if (!
|
|
11726
|
+
if (!existsSync7(pathToManifest)) {
|
|
11613
11727
|
throw new Error("Invalid integration starter cloned: missing `mesh-manifest.json`");
|
|
11614
11728
|
}
|
|
11615
11729
|
const manifestContents = readFileSync6(pathToManifest, "utf-8");
|
|
@@ -11663,12 +11777,12 @@ function validateIntegrationName(integrationName, explicitOutputPath) {
|
|
|
11663
11777
|
throw new Error("Integration name cannot be shorter than 6 characters.");
|
|
11664
11778
|
}
|
|
11665
11779
|
let targetDir = explicitOutputPath ?? process.cwd();
|
|
11666
|
-
if (!
|
|
11780
|
+
if (!existsSync7(targetDir)) {
|
|
11667
11781
|
mkdirSync3(targetDir, { recursive: true });
|
|
11668
11782
|
}
|
|
11669
|
-
if (
|
|
11783
|
+
if (readdirSync2(targetDir).length > 0) {
|
|
11670
11784
|
targetDir = path7.resolve(targetDir, typeSlug);
|
|
11671
|
-
if (
|
|
11785
|
+
if (existsSync7(targetDir)) {
|
|
11672
11786
|
throw new Error(`${targetDir} directory already exists, choose a different name.`);
|
|
11673
11787
|
}
|
|
11674
11788
|
}
|
|
@@ -11929,9 +12043,9 @@ var PolicyDocumentsPullModule = {
|
|
|
11929
12043
|
};
|
|
11930
12044
|
|
|
11931
12045
|
// src/commands/policy-documents/commands/push.ts
|
|
11932
|
-
import { existsSync as
|
|
12046
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync4 } from "fs";
|
|
11933
12047
|
import { readdir as readdir2 } from "fs/promises";
|
|
11934
|
-
import { extname as extname3, join as
|
|
12048
|
+
import { extname as extname3, join as join13 } from "path";
|
|
11935
12049
|
async function readLocalPolicyDocuments(directory, format, verbose) {
|
|
11936
12050
|
const files = await readdir2(directory);
|
|
11937
12051
|
const policyDocuments = {};
|
|
@@ -11941,7 +12055,7 @@ async function readLocalPolicyDocuments(directory, format, verbose) {
|
|
|
11941
12055
|
if (ext !== `.${format}` && ext !== ".yaml" && ext !== ".yml" && ext !== ".json") {
|
|
11942
12056
|
continue;
|
|
11943
12057
|
}
|
|
11944
|
-
const filePath =
|
|
12058
|
+
const filePath = join13(directory, filename);
|
|
11945
12059
|
try {
|
|
11946
12060
|
let roleId = filename.replace(ext, "");
|
|
11947
12061
|
const fileContent = readFileToObject(filePath);
|
|
@@ -12047,7 +12161,7 @@ var PolicyDocumentsPushModule = {
|
|
|
12047
12161
|
allowEmptySource,
|
|
12048
12162
|
verbose
|
|
12049
12163
|
}) => {
|
|
12050
|
-
if (!
|
|
12164
|
+
if (!existsSync8(directory)) {
|
|
12051
12165
|
if (verbose) {
|
|
12052
12166
|
console.log(`Creating directory ${directory}`);
|
|
12053
12167
|
}
|
|
@@ -13945,29 +14059,29 @@ var WhoamiCommand = {
|
|
|
13945
14059
|
import { bold as bold3, gray as gray6, green as green7 } from "colorette";
|
|
13946
14060
|
|
|
13947
14061
|
// src/updateCheck.ts
|
|
13948
|
-
import { existsSync as
|
|
14062
|
+
import { existsSync as existsSync9, promises as fs8 } from "fs";
|
|
13949
14063
|
import { get as getHttp } from "http";
|
|
13950
14064
|
import { get as getHttps } from "https";
|
|
13951
14065
|
import { tmpdir as tmpdir2 } from "os";
|
|
13952
|
-
import { join as
|
|
14066
|
+
import { join as join14 } from "path";
|
|
13953
14067
|
import registryUrl from "registry-url";
|
|
13954
14068
|
import { URL as URL2 } from "url";
|
|
13955
14069
|
var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
|
|
13956
14070
|
var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
|
|
13957
14071
|
var getFile = async (details, distTag) => {
|
|
13958
14072
|
const rootDir = tmpdir2();
|
|
13959
|
-
const subDir =
|
|
13960
|
-
if (!
|
|
14073
|
+
const subDir = join14(rootDir, "update-check");
|
|
14074
|
+
if (!existsSync9(subDir)) {
|
|
13961
14075
|
await fs8.mkdir(subDir);
|
|
13962
14076
|
}
|
|
13963
14077
|
let name = `${details.name}-${distTag}.json`;
|
|
13964
14078
|
if (details.scope) {
|
|
13965
14079
|
name = `${details.scope}-${name}`;
|
|
13966
14080
|
}
|
|
13967
|
-
return
|
|
14081
|
+
return join14(subDir, name);
|
|
13968
14082
|
};
|
|
13969
14083
|
var evaluateCache = async (file, time, interval) => {
|
|
13970
|
-
if (
|
|
14084
|
+
if (existsSync9(file)) {
|
|
13971
14085
|
const content = await fs8.readFile(file, "utf8");
|
|
13972
14086
|
const { lastUpdate, latest } = JSON.parse(content);
|
|
13973
14087
|
const nextCheck = lastUpdate + interval;
|
|
@@ -13990,7 +14104,7 @@ var updateCache = async (file, latest, lastUpdate) => {
|
|
|
13990
14104
|
});
|
|
13991
14105
|
await fs8.writeFile(file, content, "utf8");
|
|
13992
14106
|
};
|
|
13993
|
-
var loadPackage = ({ url, timeout }, authInfo) => new Promise((
|
|
14107
|
+
var loadPackage = ({ url, timeout }, authInfo) => new Promise((resolve6, reject) => {
|
|
13994
14108
|
const options = {
|
|
13995
14109
|
host: url.hostname,
|
|
13996
14110
|
path: url.pathname,
|
|
@@ -14021,7 +14135,7 @@ var loadPackage = ({ url, timeout }, authInfo) => new Promise((resolve4, reject)
|
|
|
14021
14135
|
response.on("end", () => {
|
|
14022
14136
|
try {
|
|
14023
14137
|
const parsedData = JSON.parse(rawData);
|
|
14024
|
-
|
|
14138
|
+
resolve6(parsedData);
|
|
14025
14139
|
} catch (e) {
|
|
14026
14140
|
reject(e);
|
|
14027
14141
|
}
|
|
@@ -14119,7 +14233,7 @@ var checkForUpdateMiddleware = async ({ verbose }) => {
|
|
|
14119
14233
|
|
|
14120
14234
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
14121
14235
|
import { magenta, red as red8 } from "colorette";
|
|
14122
|
-
import { join as
|
|
14236
|
+
import { join as join15 } from "path";
|
|
14123
14237
|
var uniformStrictVersions = [
|
|
14124
14238
|
"@uniformdev/canvas",
|
|
14125
14239
|
"@uniformdev/canvas-next",
|
|
@@ -14141,7 +14255,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
14141
14255
|
try {
|
|
14142
14256
|
let isOutside = false;
|
|
14143
14257
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
14144
|
-
const localPackages = await tryReadJSON(
|
|
14258
|
+
const localPackages = await tryReadJSON(join15(process.cwd(), "package.json"));
|
|
14145
14259
|
if (!localPackages) return;
|
|
14146
14260
|
let firstVersion;
|
|
14147
14261
|
const allDependencies = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "20.72.3-alpha.
|
|
3
|
+
"version": "20.72.3-alpha.23+cbe06f1e8a",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@inquirer/prompts": "^8.5.2",
|
|
29
29
|
"@thi.ng/mime": "^2.2.23",
|
|
30
|
-
"@uniformdev/assets": "20.72.3-alpha.
|
|
31
|
-
"@uniformdev/automations-sdk": "20.72.3-alpha.
|
|
32
|
-
"@uniformdev/canvas": "20.72.3-alpha.
|
|
33
|
-
"@uniformdev/context": "20.72.3-alpha.
|
|
34
|
-
"@uniformdev/files": "20.72.3-alpha.
|
|
35
|
-
"@uniformdev/project-map": "20.72.3-alpha.
|
|
36
|
-
"@uniformdev/redirect": "20.72.3-alpha.
|
|
37
|
-
"@uniformdev/richtext": "20.72.3-alpha.
|
|
30
|
+
"@uniformdev/assets": "20.72.3-alpha.23+cbe06f1e8a",
|
|
31
|
+
"@uniformdev/automations-sdk": "20.72.3-alpha.23+cbe06f1e8a",
|
|
32
|
+
"@uniformdev/canvas": "20.72.3-alpha.23+cbe06f1e8a",
|
|
33
|
+
"@uniformdev/context": "20.72.3-alpha.23+cbe06f1e8a",
|
|
34
|
+
"@uniformdev/files": "20.72.3-alpha.23+cbe06f1e8a",
|
|
35
|
+
"@uniformdev/project-map": "20.72.3-alpha.23+cbe06f1e8a",
|
|
36
|
+
"@uniformdev/redirect": "20.72.3-alpha.23+cbe06f1e8a",
|
|
37
|
+
"@uniformdev/richtext": "20.72.3-alpha.23+cbe06f1e8a",
|
|
38
38
|
"call-bind": "^1.0.2",
|
|
39
39
|
"colorette": "2.0.20",
|
|
40
40
|
"cosmiconfig": "9.0.2",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "cbe06f1e8a5bb93b0e3cae6b1c8774f21c10506e"
|
|
82
82
|
}
|