@uniformdev/cli 18.17.1-alpha.13 → 18.18.1-alpha.12

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 (3) hide show
  1. package/dist/index.js +322 -322
  2. package/dist/index.mjs +322 -322
  3. package/package.json +6 -6
package/dist/index.mjs CHANGED
@@ -2743,104 +2743,189 @@ var ContextCommand = {
2743
2743
  }
2744
2744
  };
2745
2745
 
2746
- // src/commands/new/commands/new.ts
2747
- import inquirer4 from "inquirer";
2748
-
2749
- // src/commands/new/actions/chooseTeam.ts
2750
- import inquirer from "inquirer";
2751
- async function chooseTeam(user, prompt, telemetry) {
2752
- const result = await inquirer.prompt([
2753
- {
2754
- type: "list",
2755
- name: "teamId",
2756
- message: prompt,
2757
- choices: user.teams.map((team) => ({
2758
- name: team.team.name,
2759
- value: team.team.id
2760
- }))
2761
- }
2762
- ]);
2763
- telemetry.send("team picked", { teamId: result.teamId });
2764
- return result;
2765
- }
2746
+ // src/spinner.ts
2747
+ var makeSpinner = () => {
2748
+ const spinners = [];
2749
+ const stopAllSpinners = () => spinners.forEach((spinner) => spinner.stop());
2750
+ const spin = async (text) => {
2751
+ const spinner = await Promise.resolve().then(() => __toESM(__require("ora"))).then((ora) => ora.default(text).start());
2752
+ spinners.push(spinner);
2753
+ const minWait = new Promise((resolve) => setTimeout(resolve, 500));
2754
+ return async () => {
2755
+ await minWait;
2756
+ spinner.stop();
2757
+ };
2758
+ };
2759
+ return { stopAllSpinners, spin };
2760
+ };
2766
2761
 
2767
- // src/commands/new/actions/cloneStarter.ts
2762
+ // src/telemetry/telemetry.ts
2768
2763
  import crypto from "crypto";
2769
- import fs from "fs";
2770
- import { copy } from "fs-jetpack";
2771
- import * as git from "isomorphic-git";
2772
- import * as http from "isomorphic-git/http/node";
2773
- import os from "os";
2774
- import path from "path";
2764
+ import { PostHog } from "posthog-node";
2775
2765
 
2776
- // src/commands/new/npm.ts
2777
- import execa from "execa";
2778
- var runNpm = async (workDir, args, { inherit, env } = {}) => {
2779
- let result;
2780
- try {
2781
- result = await execa("npm", args, {
2782
- cwd: workDir,
2783
- env: env != null ? env : {},
2784
- ...inherit ? { stdout: "inherit", stderr: "inherit" } : {}
2785
- });
2786
- } catch (err) {
2787
- throw new Error(`Failed to execute npm ${args.join(" ")}
2788
- ${err.message}`);
2789
- }
2790
- if (result.exitCode !== 0) {
2791
- throw new Error(`Command npm ${args.join(" ")} exitted with code ${result == null ? void 0 : result.exitCode}}: ${result.stderr}`);
2766
+ // package.json
2767
+ var package_default = {
2768
+ name: "@uniformdev/cli",
2769
+ version: "18.18.0",
2770
+ description: "Uniform command line interface tool",
2771
+ license: "SEE LICENSE IN LICENSE.txt",
2772
+ main: "./cli.js",
2773
+ types: "./dist/index.d.ts",
2774
+ sideEffects: false,
2775
+ scripts: {
2776
+ uniform: "node ./cli.js",
2777
+ build: "tsup",
2778
+ dev: "tsup --watch",
2779
+ clean: "rimraf dist",
2780
+ test: "jest --maxWorkers=1 --passWithNoTests",
2781
+ lint: 'eslint "src/**/*.{js,ts,tsx}"',
2782
+ format: 'prettier --write "src/**/*.{js,ts,tsx}"'
2783
+ },
2784
+ dependencies: {
2785
+ "@uniformdev/canvas": "workspace:*",
2786
+ "@uniformdev/context": "workspace:*",
2787
+ "@uniformdev/project-map": "workspace:*",
2788
+ execa: "5.1.1",
2789
+ "fs-jetpack": "5.1.0",
2790
+ graphql: "16.6.0",
2791
+ "graphql-request": "5.1.0",
2792
+ inquirer: "8.2.5",
2793
+ "isomorphic-git": "1.21.0",
2794
+ jsonwebtoken: "9.0.0",
2795
+ open: "8.4.0",
2796
+ ora: "6.1.2",
2797
+ "posthog-node": "2.2.3",
2798
+ slugify: "1.6.5",
2799
+ diff: "^5.0.0",
2800
+ dotenv: "^16.0.3",
2801
+ "https-proxy-agent": "^5.0.1",
2802
+ "isomorphic-unfetch": "^3.1.0",
2803
+ "js-yaml": "^4.1.0",
2804
+ "lodash.isequalwith": "^4.4.0",
2805
+ yargs: "^17.6.2",
2806
+ zod: "3.20.6"
2807
+ },
2808
+ devDependencies: {
2809
+ "@types/inquirer": "9.0.3",
2810
+ "@types/jsonwebtoken": "9.0.1",
2811
+ "@types/node": "18.11.17",
2812
+ "@types/diff": "5.0.2",
2813
+ "@types/js-yaml": "4.0.5",
2814
+ "@types/lodash.isequalwith": "4.4.7",
2815
+ "@types/yargs": "17.0.22",
2816
+ "p-limit": "4.0.0"
2817
+ },
2818
+ bin: {
2819
+ uniform: "./cli.js"
2820
+ },
2821
+ files: [
2822
+ "/dist"
2823
+ ],
2824
+ publishConfig: {
2825
+ access: "public"
2792
2826
  }
2793
- return result.stdout;
2794
2827
  };
2795
2828
 
2796
- // src/commands/new/actions/cloneStarter.ts
2797
- async function cloneStarter({
2798
- spin,
2799
- githubPath,
2800
- targetDir,
2801
- dotEnvFile
2802
- }) {
2803
- const done = await spin("Fetching starter code...");
2804
- const cloneDir = path.join(os.tmpdir(), `uniform-new-${crypto.randomBytes(20).toString("hex")}`);
2805
- const [user, repo, ...pathSegments] = githubPath.split("/");
2806
- try {
2807
- await git.clone({
2808
- fs,
2809
- http,
2810
- url: `https://github.com/${user}/${repo}`,
2811
- dir: cloneDir,
2812
- singleBranch: true,
2813
- depth: 1
2829
+ // src/telemetry/telemetry.ts
2830
+ var POSTHOG_WRITE_ONLY_KEY = "phc_c8YoKI9984KOHBfNrCRfIKvL56aYd5OpYxOdYexRzH7";
2831
+ var Telemetry = class {
2832
+ constructor(prefix, disable = false) {
2833
+ this.prefix = prefix;
2834
+ this.distinctId = crypto.randomBytes(20).toString("hex");
2835
+ if (!disable) {
2836
+ this.posthog = new PostHog(POSTHOG_WRITE_ONLY_KEY, {
2837
+ flushAt: 1,
2838
+ flushInterval: 1
2839
+ });
2840
+ this.send("started");
2841
+ }
2842
+ }
2843
+ login(sub, user) {
2844
+ if (!this.posthog) {
2845
+ return;
2846
+ }
2847
+ const alias = this.distinctId;
2848
+ this.distinctId = sub;
2849
+ this.posthog.alias({ distinctId: this.distinctId, alias });
2850
+ this.posthog.identify({
2851
+ distinctId: this.distinctId,
2852
+ properties: {
2853
+ email: user.email_address,
2854
+ sub,
2855
+ teamCount: user.teams.length
2856
+ }
2814
2857
  });
2815
- } catch (err) {
2816
- throw new Error(`Failed to fetch starter code: ${err.message}`);
2858
+ this.send("logged in");
2817
2859
  }
2818
- await done();
2819
- if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
2820
- throw new Error(`"${targetDir}" is not empty`);
2860
+ send(event, properties = {}) {
2861
+ var _a;
2862
+ (_a = this.posthog) == null ? void 0 : _a.capture({
2863
+ distinctId: this.distinctId,
2864
+ event: [this.prefix, event].join(" "),
2865
+ properties: {
2866
+ version: package_default.version,
2867
+ ...properties
2868
+ }
2869
+ });
2821
2870
  }
2822
- const starterDir = path.join(cloneDir, ...pathSegments);
2823
- copy(starterDir, targetDir, { overwrite: true });
2824
- if (dotEnvFile) {
2825
- fs.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
2871
+ shutdown() {
2872
+ var _a;
2873
+ this.send("exited", { exitCode: process.exitCode });
2874
+ return (_a = this.posthog) == null ? void 0 : _a.shutdownAsync();
2826
2875
  }
2827
- console.log(`
2828
- Your project now lives in ${targetDir} \u2728`);
2829
- return {
2830
- runNpmInstall: async () => {
2831
- console.log(`
2832
- Installing project dependencies...
2876
+ };
2833
2877
 
2834
- `);
2835
- await runNpm(targetDir, ["i"], { inherit: true });
2878
+ // src/commands/new/commands/new.ts
2879
+ import inquirer4 from "inquirer";
2880
+
2881
+ // src/auth/getBearerToken.ts
2882
+ import inquirer from "inquirer";
2883
+ import jwt from "jsonwebtoken";
2884
+ import open from "open";
2885
+
2886
+ // src/url.ts
2887
+ var makeUrl = (baseUrl, path4) => [baseUrl.trim().replace(/\/+$/, ""), path4.trim().replace(/^\/+/, "")].join("/");
2888
+
2889
+ // src/auth/getBearerToken.ts
2890
+ async function getBearerToken(baseUrl) {
2891
+ const { canOpen } = await inquirer.prompt([
2892
+ {
2893
+ type: "confirm",
2894
+ name: "canOpen",
2895
+ message: "Can we open a browser window to get a Uniform auth token?"
2836
2896
  }
2897
+ ]);
2898
+ if (canOpen) {
2899
+ open(makeUrl(baseUrl, "/cli-login"));
2900
+ }
2901
+ const tokenAnswer = await inquirer.prompt([
2902
+ {
2903
+ type: "password",
2904
+ name: "authToken",
2905
+ message: "Paste your Uniform auth token"
2906
+ }
2907
+ ]);
2908
+ const authToken = tokenAnswer.authToken.trim();
2909
+ if (!authToken) {
2910
+ throw new Error("No auth token provided.");
2911
+ }
2912
+ const decoded = jwt.decode(authToken, { complete: false });
2913
+ if (!decoded) {
2914
+ throw new Error("Could not parse the token pasted.");
2915
+ }
2916
+ if (typeof decoded.sub !== "string" || typeof decoded === "string") {
2917
+ throw new Error("Invalid token pasted.");
2918
+ }
2919
+ return {
2920
+ authToken,
2921
+ decoded: { ...decoded, sub: decoded.sub }
2837
2922
  };
2838
2923
  }
2839
2924
 
2840
- // src/commands/new/client.ts
2925
+ // src/client.ts
2841
2926
  import { z } from "zod";
2842
2927
 
2843
- // src/commands/new/api-key.ts
2928
+ // src/auth/api-key.ts
2844
2929
  var READ_PERMISSIONS = ["PROJECT", "UPM_PUB", "OPT_PUB", "OPT_READ", "UPM_READ"];
2845
2930
  var WRITE_PERMISSIONS = [
2846
2931
  "PROJECT",
@@ -2888,10 +2973,7 @@ var makeApiKey = (teamId, projectId, name, permissions) => ({
2888
2973
  var makeReadApiKey = (teamId, projectId) => makeApiKey(teamId, projectId, "Created by Uniform New (read)", READ_PERMISSIONS);
2889
2974
  var makeWriteApiKey = (teamId, projectId) => makeApiKey(teamId, projectId, "Created by Uniform New (write)", WRITE_PERMISSIONS);
2890
2975
 
2891
- // src/commands/new/url.ts
2892
- var makeUrl = (baseUrl, path4) => [baseUrl.trim().replace(/\/+$/, ""), path4.trim().replace(/^\/+/, "")].join("/");
2893
-
2894
- // src/commands/new/client.ts
2976
+ // src/client.ts
2895
2977
  var createTeamOrProjectSchema = z.object({ id: z.string().min(1) });
2896
2978
  var createApiKeySchema = z.object({ apiKey: z.string().min(1) });
2897
2979
  var getLimitsSchema = z.object({
@@ -3034,124 +3116,80 @@ var createClient = (baseUrl, authToken) => {
3034
3116
  };
3035
3117
  };
3036
3118
 
3037
- // src/commands/new/user-info.ts
3038
- import { gql, request } from "graphql-request";
3039
- import { z as z2 } from "zod";
3040
- var query = gql`
3041
- query GetUserInfo($subject: String!) {
3042
- info: identities_by_pk(subject: $subject) {
3043
- name
3044
- email_address
3045
- teams: organizations_identities {
3046
- team: organization {
3047
- name
3048
- id
3049
- sites {
3050
- name
3051
- id
3052
- }
3053
- }
3054
- }
3055
- }
3056
- }
3057
- `;
3058
- var schema = z2.object({
3059
- info: z2.object({
3060
- name: z2.string().min(1),
3061
- email_address: z2.string().min(1),
3062
- teams: z2.array(
3063
- z2.object({
3064
- team: z2.object({
3065
- name: z2.string().min(1),
3066
- id: z2.string().min(1),
3067
- sites: z2.array(
3068
- z2.object({
3069
- name: z2.string().min(1),
3070
- id: z2.string().min(1)
3071
- })
3072
- )
3073
- })
3074
- })
3075
- )
3076
- })
3077
- });
3078
- var getUserInfo = async (baseUrl, authToken, subject) => {
3119
+ // src/npm.ts
3120
+ import execa from "execa";
3121
+ var runNpm = async (workDir, args, { inherit, env } = {}) => {
3122
+ let result;
3079
3123
  try {
3080
- const endpoint = makeUrl(baseUrl, "/v1/graphql");
3081
- const res = await request(endpoint, query, { subject }, { Authorization: `Bearer ${authToken}` });
3082
- const parseResult = schema.safeParse(res);
3083
- if (parseResult.success) {
3084
- return parseResult.data.info;
3085
- } else {
3086
- throw new Error(`Invalid GraphQL response: ${parseResult.error.message}`);
3087
- }
3124
+ result = await execa("npm", args, {
3125
+ cwd: workDir,
3126
+ env: env != null ? env : {},
3127
+ ...inherit ? { stdout: "inherit", stderr: "inherit" } : {}
3128
+ });
3088
3129
  } catch (err) {
3089
- throw new Error(`Failed to fetch user account:
3090
- ${err.message}`);
3130
+ throw new Error(`Failed to execute npm ${args.join(" ")}
3131
+ ${err.message}`);
3091
3132
  }
3133
+ if (result.exitCode !== 0) {
3134
+ throw new Error(`Command npm ${args.join(" ")} exitted with code ${result == null ? void 0 : result.exitCode}}: ${result.stderr}`);
3135
+ }
3136
+ return result.stdout;
3092
3137
  };
3093
3138
 
3094
- // src/commands/new/actions/fetchUserAndEnsureTeamExists.ts
3095
- async function fetchUserAndEnsureFirstTeamExists({
3096
- baseUrl,
3097
- auth: { authToken, decoded },
3139
+ // src/projects/cloneStarter.ts
3140
+ import crypto2 from "crypto";
3141
+ import fs from "fs";
3142
+ import { copy } from "fs-jetpack";
3143
+ import * as git from "isomorphic-git";
3144
+ import * as http from "isomorphic-git/http/node";
3145
+ import os from "os";
3146
+ import path from "path";
3147
+ async function cloneStarter({
3098
3148
  spin,
3099
- telemetry
3149
+ githubPath,
3150
+ targetDir,
3151
+ dotEnvFile
3100
3152
  }) {
3101
- const uniformClient = createClient(baseUrl, authToken);
3102
- const done = await spin("Fetching user information...");
3103
- let user = await getUserInfo(baseUrl, authToken, decoded.sub);
3104
- if (user.teams.length < 1) {
3105
- await uniformClient.createTeam(`${user.name}'s team`);
3106
- user = await getUserInfo(baseUrl, authToken, decoded.sub);
3107
- }
3108
- await done();
3109
- telemetry.login(decoded.sub, user);
3110
- return user;
3111
- }
3112
-
3113
- // src/commands/new/actions/getBearerToken.ts
3114
- import inquirer2 from "inquirer";
3115
- import jwt from "jsonwebtoken";
3116
- import open from "open";
3117
- async function getBearerToken(baseUrl) {
3118
- const { canOpen } = await inquirer2.prompt([
3119
- {
3120
- type: "confirm",
3121
- name: "canOpen",
3122
- message: "Can we open a browser window to get a Uniform auth token?"
3123
- }
3124
- ]);
3125
- if (canOpen) {
3126
- open(makeUrl(baseUrl, "/cli-login"));
3127
- }
3128
- const tokenAnswer = await inquirer2.prompt([
3129
- {
3130
- type: "password",
3131
- name: "authToken",
3132
- message: "Paste your Uniform auth token"
3133
- }
3134
- ]);
3135
- const authToken = tokenAnswer.authToken.trim();
3136
- if (!authToken) {
3137
- throw new Error("No auth token provided.");
3153
+ const done = await spin("Fetching starter code...");
3154
+ const cloneDir = path.join(os.tmpdir(), `uniform-new-${crypto2.randomBytes(20).toString("hex")}`);
3155
+ const [user, repo, ...pathSegments] = githubPath.split("/");
3156
+ try {
3157
+ await git.clone({
3158
+ fs,
3159
+ http,
3160
+ url: `https://github.com/${user}/${repo}`,
3161
+ dir: cloneDir,
3162
+ singleBranch: true,
3163
+ depth: 1
3164
+ });
3165
+ } catch (err) {
3166
+ throw new Error(`Failed to fetch starter code: ${err.message}`);
3138
3167
  }
3139
- const decoded = jwt.decode(authToken, { complete: false });
3140
- if (!decoded) {
3141
- throw new Error("Could not parse the token pasted.");
3168
+ await done();
3169
+ if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
3170
+ throw new Error(`"${targetDir}" is not empty`);
3142
3171
  }
3143
- if (typeof decoded.sub !== "string" || typeof decoded === "string") {
3144
- throw new Error("Invalid token pasted.");
3172
+ const starterDir = path.join(cloneDir, ...pathSegments);
3173
+ copy(starterDir, targetDir, { overwrite: true });
3174
+ if (dotEnvFile) {
3175
+ fs.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
3145
3176
  }
3177
+ console.log(`
3178
+ Your project now lives in ${targetDir} \u2728`);
3146
3179
  return {
3147
- authToken,
3148
- decoded: { ...decoded, sub: decoded.sub }
3180
+ runNpmInstall: async () => {
3181
+ console.log(`
3182
+ Installing project dependencies...
3183
+
3184
+ `);
3185
+ await runNpm(targetDir, ["i"], { inherit: true });
3186
+ }
3149
3187
  };
3150
3188
  }
3151
3189
 
3152
- // src/commands/new/actions/getOrCreateProject.ts
3190
+ // src/projects/getOrCreateProject.ts
3153
3191
  import fs2, { existsSync, mkdirSync } from "fs";
3154
- import inquirer3 from "inquirer";
3192
+ import inquirer2 from "inquirer";
3155
3193
  import path2 from "path";
3156
3194
  import slugify from "slugify";
3157
3195
  var newProjectId = "$new";
@@ -3209,7 +3247,7 @@ async function getNewProjectName({
3209
3247
  }) {
3210
3248
  let projectName = explicitName;
3211
3249
  if (!projectName) {
3212
- const answer = await inquirer3.prompt([
3250
+ const answer = await inquirer2.prompt([
3213
3251
  {
3214
3252
  type: "input",
3215
3253
  name: "name",
@@ -3253,7 +3291,7 @@ async function chooseExistingProject({
3253
3291
  value: t.id
3254
3292
  }));
3255
3293
  const choices = createNew ? [{ name: "Create new project...", value: newProjectId }].concat(projects) : projects;
3256
- const result = await inquirer3.prompt([
3294
+ const result = await inquirer2.prompt([
3257
3295
  {
3258
3296
  type: "list",
3259
3297
  name: "projectId",
@@ -3287,6 +3325,100 @@ function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
3287
3325
  }
3288
3326
  }
3289
3327
 
3328
+ // src/teams/chooseTeam.ts
3329
+ import inquirer3 from "inquirer";
3330
+ async function chooseTeam(user, prompt, telemetry) {
3331
+ const result = await inquirer3.prompt([
3332
+ {
3333
+ type: "list",
3334
+ name: "teamId",
3335
+ message: prompt,
3336
+ choices: user.teams.map((team) => ({
3337
+ name: team.team.name,
3338
+ value: team.team.id
3339
+ }))
3340
+ }
3341
+ ]);
3342
+ telemetry.send("team picked", { teamId: result.teamId });
3343
+ return result;
3344
+ }
3345
+
3346
+ // src/auth/user-info.ts
3347
+ import { gql, request } from "graphql-request";
3348
+ import { z as z2 } from "zod";
3349
+ var query = gql`
3350
+ query GetUserInfo($subject: String!) {
3351
+ info: identities_by_pk(subject: $subject) {
3352
+ name
3353
+ email_address
3354
+ teams: organizations_identities {
3355
+ team: organization {
3356
+ name
3357
+ id
3358
+ sites {
3359
+ name
3360
+ id
3361
+ }
3362
+ }
3363
+ }
3364
+ }
3365
+ }
3366
+ `;
3367
+ var schema = z2.object({
3368
+ info: z2.object({
3369
+ name: z2.string().min(1),
3370
+ email_address: z2.string().min(1),
3371
+ teams: z2.array(
3372
+ z2.object({
3373
+ team: z2.object({
3374
+ name: z2.string().min(1),
3375
+ id: z2.string().min(1),
3376
+ sites: z2.array(
3377
+ z2.object({
3378
+ name: z2.string().min(1),
3379
+ id: z2.string().min(1)
3380
+ })
3381
+ )
3382
+ })
3383
+ })
3384
+ )
3385
+ })
3386
+ });
3387
+ var getUserInfo = async (baseUrl, authToken, subject) => {
3388
+ try {
3389
+ const endpoint = makeUrl(baseUrl, "/v1/graphql");
3390
+ const res = await request(endpoint, query, { subject }, { Authorization: `Bearer ${authToken}` });
3391
+ const parseResult = schema.safeParse(res);
3392
+ if (parseResult.success) {
3393
+ return parseResult.data.info;
3394
+ } else {
3395
+ throw new Error(`Invalid GraphQL response: ${parseResult.error.message}`);
3396
+ }
3397
+ } catch (err) {
3398
+ throw new Error(`Failed to fetch user account:
3399
+ ${err.message}`);
3400
+ }
3401
+ };
3402
+
3403
+ // src/teams/fetchUserAndEnsureTeamExists.ts
3404
+ async function fetchUserAndEnsureFirstTeamExists({
3405
+ baseUrl,
3406
+ auth: { authToken, decoded },
3407
+ spin,
3408
+ telemetry
3409
+ }) {
3410
+ const uniformClient = createClient(baseUrl, authToken);
3411
+ const done = await spin("Fetching user information...");
3412
+ let user = await getUserInfo(baseUrl, authToken, decoded.sub);
3413
+ if (user.teams.length < 1) {
3414
+ await uniformClient.createTeam(`${user.name}'s team`);
3415
+ user = await getUserInfo(baseUrl, authToken, decoded.sub);
3416
+ }
3417
+ await done();
3418
+ telemetry.login(decoded.sub, user);
3419
+ return user;
3420
+ }
3421
+
3290
3422
  // src/commands/new/commands/new.ts
3291
3423
  async function newHandler({
3292
3424
  spin,
@@ -3518,138 +3650,6 @@ function validateIntegrationName(integrationName, explicitOutputPath) {
3518
3650
  return { targetDir, typeSlug };
3519
3651
  }
3520
3652
 
3521
- // src/commands/new/spinner.ts
3522
- var makeSpinner = () => {
3523
- const spinners = [];
3524
- const stopAllSpinners = () => spinners.forEach((spinner) => spinner.stop());
3525
- const spin = async (text) => {
3526
- const spinner = await Promise.resolve().then(() => __toESM(__require("ora"))).then((ora) => ora.default(text).start());
3527
- spinners.push(spinner);
3528
- const minWait = new Promise((resolve) => setTimeout(resolve, 500));
3529
- return async () => {
3530
- await minWait;
3531
- spinner.stop();
3532
- };
3533
- };
3534
- return { stopAllSpinners, spin };
3535
- };
3536
-
3537
- // src/commands/new/telemetry.ts
3538
- import crypto2 from "crypto";
3539
- import { PostHog } from "posthog-node";
3540
-
3541
- // package.json
3542
- var package_default = {
3543
- name: "@uniformdev/cli",
3544
- version: "18.17.0",
3545
- description: "Uniform command line interface tool",
3546
- license: "SEE LICENSE IN LICENSE.txt",
3547
- main: "./cli.js",
3548
- types: "./dist/index.d.ts",
3549
- sideEffects: false,
3550
- scripts: {
3551
- uniform: "node ./cli.js",
3552
- build: "tsup",
3553
- dev: "tsup --watch",
3554
- clean: "rimraf dist",
3555
- test: "jest --maxWorkers=1 --passWithNoTests",
3556
- lint: 'eslint "src/**/*.{js,ts,tsx}"',
3557
- format: 'prettier --write "src/**/*.{js,ts,tsx}"'
3558
- },
3559
- dependencies: {
3560
- "@uniformdev/canvas": "workspace:*",
3561
- "@uniformdev/context": "workspace:*",
3562
- "@uniformdev/project-map": "workspace:*",
3563
- execa: "5.1.1",
3564
- "fs-jetpack": "5.1.0",
3565
- graphql: "16.6.0",
3566
- "graphql-request": "5.1.0",
3567
- inquirer: "8.2.5",
3568
- "isomorphic-git": "1.21.0",
3569
- jsonwebtoken: "9.0.0",
3570
- open: "8.4.0",
3571
- ora: "6.1.2",
3572
- "posthog-node": "2.2.3",
3573
- slugify: "1.6.5",
3574
- diff: "^5.0.0",
3575
- dotenv: "^16.0.3",
3576
- "https-proxy-agent": "^5.0.1",
3577
- "isomorphic-unfetch": "^3.1.0",
3578
- "js-yaml": "^4.1.0",
3579
- "lodash.isequalwith": "^4.4.0",
3580
- yargs: "^17.6.2",
3581
- zod: "3.20.2"
3582
- },
3583
- devDependencies: {
3584
- "@types/inquirer": "9.0.3",
3585
- "@types/jsonwebtoken": "9.0.1",
3586
- "@types/node": "18.11.17",
3587
- "@types/diff": "5.0.2",
3588
- "@types/js-yaml": "4.0.5",
3589
- "@types/lodash.isequalwith": "4.4.7",
3590
- "@types/yargs": "17.0.22",
3591
- "p-limit": "4.0.0"
3592
- },
3593
- bin: {
3594
- uniform: "./cli.js"
3595
- },
3596
- files: [
3597
- "/dist"
3598
- ],
3599
- publishConfig: {
3600
- access: "public"
3601
- }
3602
- };
3603
-
3604
- // src/commands/new/telemetry.ts
3605
- var POSTHOG_WRITE_ONLY_KEY = "phc_c8YoKI9984KOHBfNrCRfIKvL56aYd5OpYxOdYexRzH7";
3606
- var Telemetry = class {
3607
- constructor(prefix, disable = false) {
3608
- this.prefix = prefix;
3609
- this.distinctId = crypto2.randomBytes(20).toString("hex");
3610
- if (!disable) {
3611
- this.posthog = new PostHog(POSTHOG_WRITE_ONLY_KEY, {
3612
- flushAt: 1,
3613
- flushInterval: 1
3614
- });
3615
- this.send("started");
3616
- }
3617
- }
3618
- login(sub, user) {
3619
- if (!this.posthog) {
3620
- return;
3621
- }
3622
- const alias = this.distinctId;
3623
- this.distinctId = sub;
3624
- this.posthog.alias({ distinctId: this.distinctId, alias });
3625
- this.posthog.identify({
3626
- distinctId: this.distinctId,
3627
- properties: {
3628
- email: user.email_address,
3629
- sub,
3630
- teamCount: user.teams.length
3631
- }
3632
- });
3633
- this.send("logged in");
3634
- }
3635
- send(event, properties = {}) {
3636
- var _a;
3637
- (_a = this.posthog) == null ? void 0 : _a.capture({
3638
- distinctId: this.distinctId,
3639
- event: [this.prefix, event].join(" "),
3640
- properties: {
3641
- version: package_default.version,
3642
- ...properties
3643
- }
3644
- });
3645
- }
3646
- shutdown() {
3647
- var _a;
3648
- this.send("exited", { exitCode: process.exitCode });
3649
- return (_a = this.posthog) == null ? void 0 : _a.shutdownAsync();
3650
- }
3651
- };
3652
-
3653
3653
  // src/commands/new/index.ts
3654
3654
  var stableApiHost = "https://uniform.app";
3655
3655
  var apiHostDefault = process.env.UNIFORM_CLI_BASE_URL || stableApiHost;