@uniformdev/cli 20.32.1-alpha.3 → 20.32.1-alpha.4

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.
Files changed (2) hide show
  1. package/dist/index.mjs +80 -26
  2. package/package.json +10 -9
package/dist/index.mjs CHANGED
@@ -8324,6 +8324,39 @@ import yargs25 from "yargs";
8324
8324
  // src/commands/integration/commands/definition/edgehancer/deploy.ts
8325
8325
  import { readFileSync } from "fs";
8326
8326
 
8327
+ // src/commands/integration/commands/definition/bundleWorkerCode.ts
8328
+ import esbuild from "esbuild";
8329
+ import path from "path";
8330
+ async function bundleWorkerCode(entryFile) {
8331
+ const result = await esbuild.build({
8332
+ entryPoints: [entryFile],
8333
+ bundle: true,
8334
+ // Don't write to disk, build to memory
8335
+ write: false,
8336
+ format: "esm",
8337
+ target: "es2021",
8338
+ platform: "browser",
8339
+ minify: true,
8340
+ // Force inlining of all dependencies
8341
+ external: [],
8342
+ // Ensure single file output
8343
+ splitting: false,
8344
+ sourcemap: false
8345
+ });
8346
+ const outputFiles = result.outputFiles;
8347
+ if (!outputFiles || outputFiles.length === 0) {
8348
+ throw new Error(`No output generated for ${entryFile}`);
8349
+ }
8350
+ const outputFile = outputFiles[0];
8351
+ const builtCode = outputFile.text;
8352
+ console.log(
8353
+ `\u2139\uFE0F ${path.basename(entryFile)} was prepared with esbuild. Size: ${Math.round(
8354
+ builtCode.length / 1024
8355
+ )}kb (use --skipBundle to disable)`
8356
+ );
8357
+ return builtCode;
8358
+ }
8359
+
8327
8360
  // src/commands/integration/commands/definition/edgehancer/EdgehancerClient.ts
8328
8361
  import { createLimitPolicy as createLimitPolicy2 } from "@uniformdev/canvas";
8329
8362
  import { ApiClient } from "@uniformdev/context/api";
@@ -8388,6 +8421,10 @@ var IntegrationEdgehancerDeployModule = {
8388
8421
  }).option("compatibilityDate", {
8389
8422
  type: "string",
8390
8423
  describe: "Date indicating targeted support in the custom edgehancer runtime. Backwards incompatible fixes to the runtime following this date will not affect this custom edgehancer. Format: YYYY-MM-DD. You can check here for more information: https://developers.cloudflare.com/workers/configuration/compatibility-dates/#setting-compatibility-date"
8424
+ }).option("skipBundle", {
8425
+ type: "boolean",
8426
+ default: false,
8427
+ describe: "Skip bundling and transpilation of the input file"
8391
8428
  })
8392
8429
  )
8393
8430
  )
@@ -8402,11 +8439,17 @@ var IntegrationEdgehancerDeployModule = {
8402
8439
  archetype,
8403
8440
  connectorType,
8404
8441
  hook,
8405
- compatibilityDate
8442
+ compatibilityDate,
8443
+ skipBundle = false
8406
8444
  }) => {
8407
8445
  const fetch2 = nodeFetchProxy(proxy);
8408
8446
  const client = new EdgehancerClient({ apiKey, apiHost, fetch: fetch2, teamId });
8409
- const code = readFileSync(filename, "utf8");
8447
+ let code;
8448
+ if (skipBundle) {
8449
+ code = readFileSync(filename, "utf8");
8450
+ } else {
8451
+ code = await bundleWorkerCode(filename);
8452
+ }
8410
8453
  await client.deploy({ archetype, code, connectorType, hook, compatibilityDate });
8411
8454
  }
8412
8455
  };
@@ -8468,6 +8511,10 @@ var IntegrationPropertyEditorDeployModule = {
8468
8511
  }).option("compatibilityDate", {
8469
8512
  type: "string",
8470
8513
  describe: "Date indicating targeted support in the custom property editor runtime. Backwards incompatible fixes to the runtime following this date will not affect this custom property editor. Format: YYYY-MM-DD. You can check here for more information: https://developers.cloudflare.com/workers/configuration/compatibility-dates/#setting-compatibility-date"
8514
+ }).option("skipBundle", {
8515
+ type: "boolean",
8516
+ default: false,
8517
+ describe: "Skip bundling and transpilation of the input file"
8471
8518
  })
8472
8519
  )
8473
8520
  )
@@ -8481,11 +8528,17 @@ var IntegrationPropertyEditorDeployModule = {
8481
8528
  team: teamId,
8482
8529
  propertyType,
8483
8530
  hook,
8484
- compatibilityDate
8531
+ compatibilityDate,
8532
+ skipBundle = false
8485
8533
  }) => {
8486
8534
  const fetch2 = nodeFetchProxy(proxy);
8487
8535
  const client = new IntegrationPropertyEditorsClient({ apiKey, apiHost, fetch: fetch2, teamId });
8488
- const code = readFileSync2(filename, "utf8");
8536
+ let code;
8537
+ if (skipBundle) {
8538
+ code = readFileSync2(filename, "utf8");
8539
+ } else {
8540
+ code = await bundleWorkerCode(filename);
8541
+ }
8489
8542
  await client.deploy({ propertyType, code, hook, compatibilityDate });
8490
8543
  }
8491
8544
  };
@@ -8750,6 +8803,7 @@ var package_default = {
8750
8803
  "cosmiconfig-typescript-loader": "5.0.0",
8751
8804
  diff: "^5.0.0",
8752
8805
  dotenv: "^16.4.7",
8806
+ esbuild: "0.25.0",
8753
8807
  execa: "5.1.1",
8754
8808
  "file-type": "^20.0.0",
8755
8809
  "fs-jetpack": "5.1.0",
@@ -8849,7 +8903,7 @@ import jwt from "jsonwebtoken";
8849
8903
  import open from "open";
8850
8904
 
8851
8905
  // src/url.ts
8852
- var makeUrl = (baseUrl, path4) => [baseUrl.trim().replace(/\/+$/, ""), path4.trim().replace(/^\/+/, "")].join("/");
8906
+ var makeUrl = (baseUrl, path5) => [baseUrl.trim().replace(/\/+$/, ""), path5.trim().replace(/^\/+/, "")].join("/");
8853
8907
 
8854
8908
  // src/auth/getBearerToken.ts
8855
8909
  async function getBearerToken(baseUrl) {
@@ -8953,8 +9007,8 @@ var getLimitsSchema = z.object({
8953
9007
  })
8954
9008
  });
8955
9009
  var createClient = (baseUrl, authToken) => {
8956
- const request2 = async (path4, opts, allowedNon2xxStatusCodes = []) => {
8957
- const res = await fetch(makeUrl(baseUrl, path4), {
9010
+ const request2 = async (path5, opts, allowedNon2xxStatusCodes = []) => {
9011
+ const res = await fetch(makeUrl(baseUrl, path5), {
8958
9012
  ...opts,
8959
9013
  headers: { Authorization: `Bearer ${authToken}` }
8960
9014
  });
@@ -8962,18 +9016,18 @@ var createClient = (baseUrl, authToken) => {
8962
9016
  return res;
8963
9017
  } else {
8964
9018
  throw new Error(
8965
- `Non-2xx API response: ${opts.method} ${path4} responded with ${res.status} ${res.statusText}`
9019
+ `Non-2xx API response: ${opts.method} ${path5} responded with ${res.status} ${res.statusText}`
8966
9020
  );
8967
9021
  }
8968
9022
  };
8969
- const requestJson = async (path4, opts, schema2, allowedNon2xxStatusCodes = []) => {
8970
- const res = await request2(path4, opts, allowedNon2xxStatusCodes);
9023
+ const requestJson = async (path5, opts, schema2, allowedNon2xxStatusCodes = []) => {
9024
+ const res = await request2(path5, opts, allowedNon2xxStatusCodes);
8971
9025
  const data = await res.json();
8972
9026
  const parseResult = schema2.safeParse(data);
8973
9027
  if (parseResult.success) {
8974
9028
  return parseResult.data;
8975
9029
  } else {
8976
- throw new Error(`Invalid ${opts.method} ${path4} response: ${parseResult.error.message}`);
9030
+ throw new Error(`Invalid ${opts.method} ${path5} response: ${parseResult.error.message}`);
8977
9031
  }
8978
9032
  };
8979
9033
  return {
@@ -9107,7 +9161,7 @@ import fsj5 from "fs-jetpack";
9107
9161
  import * as git from "isomorphic-git";
9108
9162
  import * as http from "isomorphic-git/http/node/index.js";
9109
9163
  import os from "os";
9110
- import path from "path";
9164
+ import path2 from "path";
9111
9165
  async function cloneStarter({
9112
9166
  spin,
9113
9167
  githubPath,
@@ -9116,7 +9170,7 @@ async function cloneStarter({
9116
9170
  githubBranch
9117
9171
  }) {
9118
9172
  const done = await spin("Fetching starter code...");
9119
- const cloneDir = path.join(os.tmpdir(), `uniform-new-${crypto2.randomBytes(20).toString("hex")}`);
9173
+ const cloneDir = path2.join(os.tmpdir(), `uniform-new-${crypto2.randomBytes(20).toString("hex")}`);
9120
9174
  const [user, repo, ...pathSegments] = githubPath.split("/");
9121
9175
  try {
9122
9176
  await git.clone({
@@ -9135,10 +9189,10 @@ async function cloneStarter({
9135
9189
  if (fs3.existsSync(targetDir) && fs3.readdirSync(targetDir).length > 0) {
9136
9190
  throw new Error(`"${targetDir}" is not empty`);
9137
9191
  }
9138
- const starterDir = path.join(cloneDir, ...pathSegments);
9192
+ const starterDir = path2.join(cloneDir, ...pathSegments);
9139
9193
  fsj5.copy(starterDir, targetDir, { overwrite: true });
9140
9194
  if (dotEnvFile) {
9141
- fs3.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
9195
+ fs3.writeFileSync(path2.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
9142
9196
  }
9143
9197
  console.log(`
9144
9198
  Your project now lives in ${targetDir} \u2728`);
@@ -9156,7 +9210,7 @@ Installing project dependencies...
9156
9210
  // src/projects/getOrCreateProject.ts
9157
9211
  import fs4, { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
9158
9212
  import inquirer2 from "inquirer";
9159
- import path2 from "path";
9213
+ import path3 from "path";
9160
9214
  import slugify from "slugify";
9161
9215
  var newProjectId = "$new";
9162
9216
  async function getOrCreateProject({
@@ -9281,7 +9335,7 @@ function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
9281
9335
  mkdirSync2(targetDir, { recursive: true });
9282
9336
  }
9283
9337
  if (fs4.readdirSync(targetDir).length > 0) {
9284
- targetDir = path2.resolve(targetDir, projectNameSlug);
9338
+ targetDir = path3.resolve(targetDir, projectNameSlug);
9285
9339
  if (fs4.existsSync(targetDir)) {
9286
9340
  throw new Error(`${targetDir} already exists, choose a different name.`);
9287
9341
  }
@@ -9545,7 +9599,7 @@ npm run dev
9545
9599
  // src/commands/new/commands/new-mesh-integration.ts
9546
9600
  import { existsSync as existsSync3, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
9547
9601
  import inquirer5 from "inquirer";
9548
- import path3 from "path";
9602
+ import path4 from "path";
9549
9603
  import slugify2 from "slugify";
9550
9604
  async function newMeshIntegrationHandler({
9551
9605
  spin,
@@ -9591,7 +9645,7 @@ async function newMeshIntegrationHandler({
9591
9645
  githubBranch
9592
9646
  });
9593
9647
  let done = await spin("Registering integration to team...");
9594
- const pathToManifest = path3.resolve(targetDir, "mesh-manifest.json");
9648
+ const pathToManifest = path4.resolve(targetDir, "mesh-manifest.json");
9595
9649
  if (!existsSync3(pathToManifest)) {
9596
9650
  throw new Error("Invalid integration starter cloned: missing `mesh-manifest.json`");
9597
9651
  }
@@ -9600,7 +9654,7 @@ async function newMeshIntegrationHandler({
9600
9654
  manifestJson.type = typeSlug;
9601
9655
  manifestJson.displayName = name;
9602
9656
  writeFileSync(pathToManifest, JSON.stringify(manifestJson, null, 2), "utf-8");
9603
- const packageJsonPath = path3.resolve(targetDir, "package.json");
9657
+ const packageJsonPath = path4.resolve(targetDir, "package.json");
9604
9658
  const packageJson = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
9605
9659
  packageJson.name = typeSlug;
9606
9660
  writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
@@ -9650,7 +9704,7 @@ function validateIntegrationName(integrationName, explicitOutputPath) {
9650
9704
  mkdirSync3(targetDir, { recursive: true });
9651
9705
  }
9652
9706
  if (readdirSync(targetDir).length > 0) {
9653
- targetDir = path3.resolve(targetDir, typeSlug);
9707
+ targetDir = path4.resolve(targetDir, typeSlug);
9654
9708
  if (existsSync3(targetDir)) {
9655
9709
  throw new Error(`${targetDir} directory already exists, choose a different name.`);
9656
9710
  }
@@ -11672,14 +11726,14 @@ import { join as join8 } from "path";
11672
11726
 
11673
11727
  // src/fs.ts
11674
11728
  import { promises as fs6 } from "fs";
11675
- async function readJSON(path4) {
11676
- const fileContents = await fs6.readFile(path4, "utf-8");
11729
+ async function readJSON(path5) {
11730
+ const fileContents = await fs6.readFile(path5, "utf-8");
11677
11731
  return JSON.parse(fileContents);
11678
11732
  }
11679
- async function tryReadJSON(path4, missingValue = null) {
11733
+ async function tryReadJSON(path5, missingValue = null) {
11680
11734
  try {
11681
- const stat = await fs6.stat(path4);
11682
- return stat.isFile() ? await readJSON(path4) : missingValue;
11735
+ const stat = await fs6.stat(path5);
11736
+ return stat.isFile() ? await readJSON(path5) : missingValue;
11683
11737
  } catch {
11684
11738
  return missingValue;
11685
11739
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.32.1-alpha.3+c30c2f2b0d",
3
+ "version": "20.32.1-alpha.4+d57d1b5dfa",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -27,19 +27,20 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@thi.ng/mime": "^2.2.23",
30
- "@uniformdev/assets": "20.32.1-alpha.3+c30c2f2b0d",
31
- "@uniformdev/canvas": "20.32.1-alpha.3+c30c2f2b0d",
32
- "@uniformdev/context": "20.32.1-alpha.3+c30c2f2b0d",
33
- "@uniformdev/files": "20.32.1-alpha.3+c30c2f2b0d",
34
- "@uniformdev/project-map": "20.32.1-alpha.3+c30c2f2b0d",
35
- "@uniformdev/redirect": "20.32.1-alpha.3+c30c2f2b0d",
36
- "@uniformdev/richtext": "20.32.1-alpha.3+c30c2f2b0d",
30
+ "@uniformdev/assets": "20.32.1-alpha.4+d57d1b5dfa",
31
+ "@uniformdev/canvas": "20.32.1-alpha.4+d57d1b5dfa",
32
+ "@uniformdev/context": "20.32.1-alpha.4+d57d1b5dfa",
33
+ "@uniformdev/files": "20.32.1-alpha.4+d57d1b5dfa",
34
+ "@uniformdev/project-map": "20.32.1-alpha.4+d57d1b5dfa",
35
+ "@uniformdev/redirect": "20.32.1-alpha.4+d57d1b5dfa",
36
+ "@uniformdev/richtext": "20.32.1-alpha.4+d57d1b5dfa",
37
37
  "call-bind": "^1.0.2",
38
38
  "colorette": "2.0.20",
39
39
  "cosmiconfig": "9.0.0",
40
40
  "cosmiconfig-typescript-loader": "5.0.0",
41
41
  "diff": "^5.0.0",
42
42
  "dotenv": "^16.4.7",
43
+ "esbuild": "0.25.0",
43
44
  "execa": "5.1.1",
44
45
  "file-type": "^20.0.0",
45
46
  "fs-jetpack": "5.1.0",
@@ -81,5 +82,5 @@
81
82
  "publishConfig": {
82
83
  "access": "public"
83
84
  },
84
- "gitHead": "c30c2f2b0de9d99e7c038dba9b941039f2c18a39"
85
+ "gitHead": "d57d1b5dfa94641fb683cbc7e2e9333516b4019f"
85
86
  }