@superblocksteam/cli 1.10.0 → 1.12.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.
Files changed (55) hide show
  1. package/LICENSE.txt +87 -0
  2. package/README.md +6 -6
  3. package/assets/custom-components/setup/tsconfig.json +0 -1
  4. package/bin/dev +5 -7
  5. package/bin/run +1 -3
  6. package/dist/appendHotReloadEventPlugin.mjs +43 -0
  7. package/dist/commands/commits.d.mts +18 -0
  8. package/dist/commands/{commits.js → commits.mjs} +59 -67
  9. package/dist/commands/components/{create.d.ts → create.d.mts} +2 -2
  10. package/dist/commands/components/{create.js → create.mjs} +84 -93
  11. package/dist/commands/components/{register.d.ts → register.d.mts} +1 -1
  12. package/dist/commands/components/register.mjs +12 -0
  13. package/dist/commands/components/{upload.d.ts → upload.d.mts} +2 -2
  14. package/dist/commands/components/{upload.js → upload.mjs} +39 -43
  15. package/dist/commands/components/{watch.d.ts → watch.d.mts} +1 -1
  16. package/dist/commands/components/{watch.js → watch.mjs} +29 -36
  17. package/dist/commands/config/{set.d.ts → set.d.mts} +2 -2
  18. package/dist/commands/config/{set.js → set.mjs} +28 -32
  19. package/dist/commands/{init.d.ts → init.d.mts} +4 -4
  20. package/dist/commands/{init.js → init.mjs} +58 -64
  21. package/dist/commands/{login.d.ts → login.d.mts} +1 -1
  22. package/dist/commands/login.mjs +55 -0
  23. package/dist/commands/{migrate.d.ts → migrate.d.mts} +1 -1
  24. package/dist/commands/{migrate.js → migrate.mjs} +34 -42
  25. package/dist/commands/pull.d.mts +17 -0
  26. package/dist/commands/{pull.js → pull.mjs} +72 -80
  27. package/dist/commands/push.d.mts +15 -0
  28. package/dist/commands/{push.js → push.mjs} +81 -90
  29. package/dist/commands/{rm.d.ts → rm.d.mts} +2 -2
  30. package/dist/commands/{rm.js → rm.mjs} +34 -40
  31. package/dist/common/{authenticated-command.js → authenticated-command.mjs} +65 -75
  32. package/dist/common/defaults/{create-component-defaults.js → create-component-defaults.mjs} +2 -7
  33. package/dist/common/{version-control.d.ts → version-control.d.mts} +1 -1
  34. package/dist/common/{version-control.js → version-control.mjs} +170 -202
  35. package/dist/index.js +1 -5
  36. package/dist/{productionCssPlugin.js → productionCssPlugin.mjs} +4 -10
  37. package/dist/{reactShimPlugin.js → reactShimPlugin.mjs} +17 -24
  38. package/dist/util/migrationWarningsForApplications.mjs +47 -0
  39. package/dist/util/{migrationsForDotfiles.js → migrationsForDotfiles.mjs} +10 -17
  40. package/oclif.manifest.json +274 -161
  41. package/package.json +43 -41
  42. package/dist/appendHotReloadEventPlugin.js +0 -48
  43. package/dist/commands/commits.d.ts +0 -18
  44. package/dist/commands/components/register.js +0 -15
  45. package/dist/commands/login.js +0 -61
  46. package/dist/commands/pull.d.ts +0 -17
  47. package/dist/commands/push.d.ts +0 -15
  48. package/dist/util/migrationWarningsForApplications.js +0 -52
  49. /package/dist/{appendHotReloadEventPlugin.d.ts → appendHotReloadEventPlugin.d.mts} +0 -0
  50. /package/dist/common/{authenticated-command.d.ts → authenticated-command.d.mts} +0 -0
  51. /package/dist/common/defaults/{create-component-defaults.d.ts → create-component-defaults.d.mts} +0 -0
  52. /package/dist/{productionCssPlugin.d.ts → productionCssPlugin.d.mts} +0 -0
  53. /package/dist/{reactShimPlugin.d.ts → reactShimPlugin.d.mts} +0 -0
  54. /package/dist/util/{migrationWarningsForApplications.d.ts → migrationWarningsForApplications.d.mts} +0 -0
  55. /package/dist/util/{migrationsForDotfiles.d.ts → migrationsForDotfiles.d.mts} +0 -0
@@ -1,23 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const node_child_process_1 = require("node:child_process");
5
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
6
- const node_util_1 = tslib_1.__importDefault(require("node:util"));
7
- const util_1 = require("@superblocksteam/util");
8
- const colorette_1 = require("colorette");
9
- const fs = tslib_1.__importStar(require("fs-extra"));
10
- const listr2_1 = require("listr2");
11
- const semver_1 = tslib_1.__importDefault(require("semver"));
12
- const authenticated_command_1 = require("../common/authenticated-command");
13
- const version_control_1 = require("../common/version-control");
14
- class Migrate extends authenticated_command_1.AuthenticatedCommand {
1
+ import { exec } from "node:child_process";
2
+ import path from "node:path";
3
+ import util from "node:util";
4
+ import { getSuperblocksMonorepoConfigJson, getSuperblocksResourceConfigIfExists, } from "@superblocksteam/util";
5
+ import { cyan } from "colorette";
6
+ import fs from "fs-extra";
7
+ import { Listr, } from "listr2";
8
+ import semver from "semver";
9
+ import { AuthenticatedCommand } from "../common/authenticated-command.mjs";
10
+ import { FileStructureType, MULTI_SELECT_PROMPT_HELP, atLeastOneSelection, getFileStructureType, readApplicationFromDisk, writeMultiPageApplicationToDisk, } from "../common/version-control.mjs";
11
+ export default class Migrate extends AuthenticatedCommand {
12
+ static description = "Migrate files to use the current CLI version";
13
+ static examples = ["<%= config.bin %> <%= command.id %>"];
15
14
  async run() {
16
15
  const tasks = this.createTasks();
17
16
  await tasks.run();
18
17
  }
19
18
  createTasks() {
20
- const tasks = new listr2_1.Listr([
19
+ const tasks = new Listr([
21
20
  {
22
21
  title: "Checking for existing Superblocks project...",
23
22
  task: async (ctx) => {
@@ -25,26 +24,25 @@ class Migrate extends authenticated_command_1.AuthenticatedCommand {
25
24
  [
26
25
  ctx.existingSuperblocksRootConfig,
27
26
  ctx.superblocksRootConfigPath,
28
- ] = await (0, util_1.getSuperblocksMonorepoConfigJson)(true);
27
+ ] = await getSuperblocksMonorepoConfigJson(true);
29
28
  ctx.existingSuperblocksResourceConfig =
30
- await (0, util_1.getSuperblocksResourceConfigIfExists)();
29
+ await getSuperblocksResourceConfigIfExists();
31
30
  }
32
31
  catch {
33
32
  // no existing superblocks config
34
- this.error(`No Superblocks project found in the current folder hierarchy. Run ${(0, colorette_1.cyan)("superblocks init")} to initialize a new project.`);
33
+ this.error(`No Superblocks project found in the current folder hierarchy. Run ${cyan("superblocks init")} to initialize a new project.`);
35
34
  }
36
35
  },
37
36
  },
38
37
  {
39
38
  title: "Migrating resources...",
40
39
  task: async (ctx, task) => {
41
- var _a;
42
40
  const resourceIdsToMigrate = await this.getResourceIdsToMigrate(ctx, task);
43
41
  const subtasks = [];
44
- const superblocksRootPath = node_path_1.default.resolve(node_path_1.default.dirname(ctx.superblocksRootConfigPath), "..");
42
+ const superblocksRootPath = path.resolve(path.dirname(ctx.superblocksRootConfigPath), "..");
45
43
  for (const resourceId of resourceIdsToMigrate) {
46
- const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
47
- switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
44
+ const resource = ctx.existingSuperblocksRootConfig?.resources[resourceId];
45
+ switch (resource?.resourceType) {
48
46
  case "APPLICATION": {
49
47
  subtasks.push({
50
48
  title: `Migrating application ${resource.location}...`,
@@ -81,7 +79,6 @@ class Migrate extends authenticated_command_1.AuthenticatedCommand {
81
79
  return tasks;
82
80
  }
83
81
  async getResourceIdsToMigrate(ctx, task) {
84
- var _a, _b, _c, _d, _e;
85
82
  const choices = [];
86
83
  const initialSelections = [];
87
84
  choices.push({
@@ -89,12 +86,12 @@ class Migrate extends authenticated_command_1.AuthenticatedCommand {
89
86
  message: "",
90
87
  });
91
88
  let counter = 1;
92
- for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
89
+ for (const [resourceId, resource] of Object.entries(ctx.existingSuperblocksRootConfig?.resources ?? {})) {
93
90
  choices.push({
94
91
  name: resourceId,
95
92
  message: resource.location,
96
93
  });
97
- if (((_c = ctx.existingSuperblocksResourceConfig) === null || _c === void 0 ? void 0 : _c.id) === resourceId) {
94
+ if (ctx.existingSuperblocksResourceConfig?.id === resourceId) {
98
95
  initialSelections.push(counter);
99
96
  }
100
97
  counter++;
@@ -105,25 +102,24 @@ class Migrate extends authenticated_command_1.AuthenticatedCommand {
105
102
  {
106
103
  type: "MultiSelect",
107
104
  name: "resourceIdsToMigrate",
108
- message: `Select resources to migrate (${version_control_1.MULTI_SELECT_PROMPT_HELP})`,
105
+ message: `Select resources to migrate (${MULTI_SELECT_PROMPT_HELP})`,
109
106
  choices: choices,
110
107
  initial: initialSelections,
111
- validate: version_control_1.atLeastOneSelection,
112
- // @ts-expect-error listr2 types are wrong for prefix
108
+ validate: atLeastOneSelection,
113
109
  prefix: "▸",
114
110
  indicator: "◉",
115
111
  },
116
112
  ]);
117
113
  if (resourceIdsToMigrate[0] === "All Resources") {
118
- return Object.entries((_e = (_d = ctx.existingSuperblocksRootConfig) === null || _d === void 0 ? void 0 : _d.resources) !== null && _e !== void 0 ? _e : {}).map(([id]) => id);
114
+ return Object.entries(ctx.existingSuperblocksRootConfig?.resources ?? {}).map(([id]) => id);
119
115
  }
120
116
  return resourceIdsToMigrate;
121
117
  }
122
118
  async migrateSinglePageApplicationToMultiPage(applicationResource, superblocksRootPath, featureFlags) {
123
- const fileStructure = await (0, version_control_1.getFileStructureType)(superblocksRootPath, applicationResource.location);
124
- if (fileStructure == version_control_1.FileStructureType.SINGLE_PAGE) {
119
+ const fileStructure = await getFileStructureType(superblocksRootPath, applicationResource.location);
120
+ if (fileStructure == FileStructureType.SINGLE_PAGE) {
125
121
  this.log(`Migrating single page application at ${applicationResource.location} to multi-page application...`);
126
- const singlePageApplication = await (0, version_control_1.readApplicationFromDisk)(superblocksRootPath, applicationResource.location);
122
+ const singlePageApplication = await readApplicationFromDisk(superblocksRootPath, applicationResource.location);
127
123
  const multiPageApplication = {
128
124
  application: {
129
125
  id: singlePageApplication.application.id,
@@ -141,21 +137,20 @@ class Migrate extends authenticated_command_1.AuthenticatedCommand {
141
137
  ],
142
138
  componentFiles: [],
143
139
  };
144
- await (0, version_control_1.writeMultiPageApplicationToDisk)(multiPageApplication, superblocksRootPath, featureFlags, applicationResource.location, true);
140
+ await writeMultiPageApplicationToDisk(multiPageApplication, superblocksRootPath, featureFlags, applicationResource.location, true);
145
141
  this.log(`Successfully migrated single page application at ${applicationResource.location} to multi-page application.`);
146
142
  }
147
143
  }
148
144
  async migrateCustomComponentVersion(applicationResource, superblocksRootPath) {
149
- var _a;
150
- const packageJsonPath = node_path_1.default.join(superblocksRootPath, applicationResource.location, "package.json");
145
+ const packageJsonPath = path.join(superblocksRootPath, applicationResource.location, "package.json");
151
146
  if (await fs.pathExists(packageJsonPath)) {
152
147
  this.log("Checking CLI version compatibility...");
153
148
  const packageJson = await fs.readJson(packageJsonPath);
154
- const versionStr = (_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a["@superblocksteam/custom-components"];
155
- if (!semver_1.default.satisfies(this.config.version, versionStr)) {
149
+ const versionStr = packageJson.dependencies?.["@superblocksteam/custom-components"];
150
+ if (!semver.satisfies(this.config.version, versionStr)) {
156
151
  this.log("Migrating application dependencies...");
157
- await node_util_1.default.promisify(node_child_process_1.exec)(`npm install @superblocksteam/custom-components@${this.config.version}`, {
158
- cwd: node_path_1.default.join(superblocksRootPath, applicationResource.location),
152
+ await util.promisify(exec)(`npm install @superblocksteam/custom-components@${this.config.version}`, {
153
+ cwd: path.join(superblocksRootPath, applicationResource.location),
159
154
  });
160
155
  }
161
156
  else {
@@ -178,6 +173,3 @@ class Migrate extends authenticated_command_1.AuthenticatedCommand {
178
173
  }
179
174
  }
180
175
  }
181
- Migrate.description = "Migrate files to use the current CLI version";
182
- Migrate.examples = ["<%= config.bin %> <%= command.id %>"];
183
- exports.default = Migrate;
@@ -0,0 +1,17 @@
1
+ import { AuthenticatedCommand } from "../common/authenticated-command.mjs";
2
+ export default class Pull extends AuthenticatedCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ mode: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ "commit-id": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ "skip-signing-verification": import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ static args: {
12
+ resource_path: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<void>;
15
+ private createTasks;
16
+ private getResourceIdsToPull;
17
+ }
@@ -1,21 +1,52 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
5
- const core_1 = require("@oclif/core");
6
- const sdk_1 = require("@superblocksteam/sdk");
7
- const util_1 = require("@superblocksteam/util");
8
- const listr2_1 = require("listr2");
9
- const authenticated_command_1 = require("../common/authenticated-command");
10
- const version_control_1 = require("../common/version-control");
11
- class Pull extends authenticated_command_1.AuthenticatedCommand {
1
+ import path from "node:path";
2
+ import { Args, Flags } from "@oclif/core";
3
+ import { ValidateGitSetupError, } from "@superblocksteam/sdk";
4
+ import { getSuperblocksMonorepoConfigJson, getSuperblocksResourceConfigIfExists, ComponentEvent, COMPONENT_EVENT_HEADER, NotFoundError, } from "@superblocksteam/util";
5
+ import { Listr } from "listr2";
6
+ import { AuthenticatedCommand } from "../common/authenticated-command.mjs";
7
+ import { DEFAULT_BRANCH, FileStructureType, LATEST_EDITS_MODE, MULTI_SELECT_PROMPT_HELP, atLeastOneSelection, deleteResourcesAndUpdateRootConfig, getCurrentGitBranchIfGit, getFileStructureType, getMode, isCI, modeFlagValuesMap, writeMultiPageApplicationToDisk, writeResourceToDisk, } from "../common/version-control.mjs";
8
+ export default class Pull extends AuthenticatedCommand {
9
+ static description = "Download objects from Superblocks and save them locally";
10
+ static examples = [
11
+ "<%= config.bin %> <%= command.id %>",
12
+ "<%= config.bin %> <%= command.id %> apps/my-app",
13
+ "<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
14
+ "<%= config.bin %> <%= command.id %> apps/my-app -c commit-id",
15
+ ];
16
+ static flags = {
17
+ mode: Flags.string({
18
+ char: "m",
19
+ description: "Pull mode",
20
+ options: Object.keys(modeFlagValuesMap),
21
+ default: LATEST_EDITS_MODE,
22
+ }),
23
+ branch: Flags.string({
24
+ char: "b",
25
+ description: "Superblocks branch to pull from, the current git branch will be used by default",
26
+ }),
27
+ "commit-id": Flags.string({
28
+ char: "c",
29
+ description: "Superblocks commit id to pull, the live edit will be used by default",
30
+ }),
31
+ "skip-signing-verification": Flags.boolean({
32
+ char: "s",
33
+ description: "If true, signature verification for signing enabled organizations will be skipped.",
34
+ default: false,
35
+ }),
36
+ };
37
+ static args = {
38
+ resource_path: Args.string({
39
+ description: "Superblocks resource location to pull (i.e. apps/my-app)",
40
+ required: false,
41
+ }),
42
+ };
12
43
  async run() {
13
44
  const { flags, args } = await this.parse(Pull);
14
45
  const tasks = this.createTasks(args.resource_path, flags.mode, flags.branch, flags["skip-signing-verification"], flags["commit-id"]);
15
46
  await tasks.run();
16
47
  }
17
48
  createTasks(resourcePath, mode, branch, skipSigningVerification = false, commitId) {
18
- const tasks = new listr2_1.Listr([
49
+ const tasks = new Listr([
19
50
  {
20
51
  title: "Checking for existing Superblocks project...",
21
52
  task: async (ctx) => {
@@ -27,10 +58,10 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
27
58
  [
28
59
  ctx.existingSuperblocksRootConfig,
29
60
  ctx.superblocksRootConfigPath,
30
- ] = await (0, util_1.getSuperblocksMonorepoConfigJson)(true);
61
+ ] = await getSuperblocksMonorepoConfigJson(true);
31
62
  ctx.existingSuperblocksResourceConfig =
32
- await (0, util_1.getSuperblocksResourceConfigIfExists)();
33
- ctx.superblocksRootPath = node_path_1.default.resolve(node_path_1.default.dirname(ctx.superblocksRootConfigPath), "..");
63
+ await getSuperblocksResourceConfigIfExists();
64
+ ctx.superblocksRootPath = path.resolve(path.dirname(ctx.superblocksRootConfigPath), "..");
34
65
  }
35
66
  catch {
36
67
  // no existing superblocks config
@@ -44,7 +75,7 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
44
75
  ctx.branchToPullFrom = new Map();
45
76
  try {
46
77
  ctx.localBranchName =
47
- branch || (await (0, version_control_1.getCurrentGitBranchIfGit)()) || version_control_1.DEFAULT_BRANCH;
78
+ branch || (await getCurrentGitBranchIfGit()) || DEFAULT_BRANCH;
48
79
  }
49
80
  catch (e) {
50
81
  this.error(`Failed to check for existing git repository: ${e.message}. Please make sure to clone or initialize a git repository.`);
@@ -54,10 +85,9 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
54
85
  {
55
86
  title: "Checking for deleted Superblocks resources...",
56
87
  task: async (ctx, task) => {
57
- var _a, _b;
58
88
  try {
59
- for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
60
- switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
89
+ for (const [resourceId, resource] of Object.entries(ctx.existingSuperblocksRootConfig?.resources ?? {})) {
90
+ switch (resource?.resourceType) {
61
91
  case "APPLICATION": {
62
92
  try {
63
93
  await this.getSdk().fetchApplication({
@@ -67,7 +97,7 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
67
97
  });
68
98
  }
69
99
  catch (error) {
70
- if (error instanceof util_1.NotFoundError) {
100
+ if (error instanceof NotFoundError) {
71
101
  ctx.removedResourceIds.push(resourceId);
72
102
  }
73
103
  else {
@@ -85,7 +115,7 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
85
115
  });
86
116
  }
87
117
  catch (error) {
88
- if (error instanceof util_1.NotFoundError) {
118
+ if (error instanceof NotFoundError) {
89
119
  ctx.removedResourceIds.push(resourceId);
90
120
  }
91
121
  else {
@@ -118,7 +148,7 @@ Would you like to also delete these resources from your filesystem?`,
118
148
  },
119
149
  ]);
120
150
  if (removeResourcesFromDisk) {
121
- await (0, version_control_1.deleteResourcesAndUpdateRootConfig)(ctx.removedResourceIds, ctx.existingSuperblocksRootConfig, ctx.superblocksRootPath, ctx.superblocksRootConfigPath);
151
+ await deleteResourcesAndUpdateRootConfig(ctx.removedResourceIds, ctx.existingSuperblocksRootConfig, ctx.superblocksRootPath, ctx.superblocksRootConfigPath);
122
152
  }
123
153
  }
124
154
  catch (e) {
@@ -134,22 +164,21 @@ Would you like to also delete these resources from your filesystem?`,
134
164
  },
135
165
  {
136
166
  task: async (ctx, task) => {
137
- var _a, _b;
138
167
  task.title = `Validating git configuration...`;
139
168
  const subtasks = [];
140
169
  ctx.resourceIdsToSkip = new Set();
141
170
  for (const resourceId of ctx.resourceIdsToPull) {
142
- const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
143
- const resourceTitle = `${((_b = resource.resourceType) !== null && _b !== void 0 ? _b : "").toLowerCase()} ${resourceId}`;
171
+ const resource = ctx.existingSuperblocksRootConfig?.resources[resourceId];
172
+ const resourceTitle = `${(resource.resourceType ?? "").toLowerCase()} ${resourceId}`;
144
173
  subtasks.push({
145
174
  title: `Checking ${resourceTitle}...`,
146
175
  task: async () => {
147
176
  try {
148
- const { branchName } = await this.validateGitSetup(resource === null || resource === void 0 ? void 0 : resource.resourceType, resourceId, util_1.ComponentEvent.PULL, ctx.localBranchName);
177
+ const { branchName } = await this.validateGitSetup(resource?.resourceType, resourceId, ComponentEvent.PULL, ctx.localBranchName);
149
178
  ctx.branchToPullFrom.set(resourceId, branchName);
150
179
  }
151
180
  catch (error) {
152
- if ((0, version_control_1.isCI)() && error instanceof sdk_1.ValidateGitSetupError) {
181
+ if (isCI() && error instanceof ValidateGitSetupError) {
153
182
  this.log(`WARN: Failed to validate git setup for ${resourceTitle}. Skipping pull.\n\n${error.message}.`);
154
183
  ctx.resourceIdsToSkip.add(resourceId);
155
184
  }
@@ -181,31 +210,30 @@ Would you like to also delete these resources from your filesystem?`,
181
210
  },
182
211
  {
183
212
  task: async (ctx, task) => {
184
- var _a, _b;
185
213
  task.title = `Pulling resources from branch ${ctx.localBranchName}...`;
186
214
  let viewMode;
187
215
  if (commitId) {
188
216
  viewMode = "export-commit";
189
217
  }
190
218
  else {
191
- viewMode = await (0, version_control_1.getMode)(task, mode);
219
+ viewMode = await getMode(task, mode);
192
220
  }
193
221
  const subtasks = [];
194
222
  for (const resourceId of ctx.resourceIdsToPull) {
195
- const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
196
- const branchName = (_b = ctx.branchToPullFrom.get(resourceId)) !== null && _b !== void 0 ? _b : ctx.localBranchName;
197
- switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
223
+ const resource = ctx.existingSuperblocksRootConfig?.resources[resourceId];
224
+ const branchName = ctx.branchToPullFrom.get(resourceId) ?? ctx.localBranchName;
225
+ switch (resource?.resourceType) {
198
226
  case "APPLICATION": {
199
227
  subtasks.push({
200
228
  title: `Pulling application ${resource.location} from branch ${branchName}...`,
201
229
  task: async (_ctx, task) => {
202
230
  const headers = {
203
- [util_1.COMPONENT_EVENT_HEADER]: util_1.ComponentEvent.PULL,
231
+ [COMPONENT_EVENT_HEADER]: ComponentEvent.PULL,
204
232
  };
205
233
  try {
206
234
  task.title += `: fetched`;
207
- const fileStructureType = await (0, version_control_1.getFileStructureType)(ctx.superblocksRootPath, resource.location);
208
- if (fileStructureType === version_control_1.FileStructureType.SINGLE_PAGE) {
235
+ const fileStructureType = await getFileStructureType(ctx.superblocksRootPath, resource.location);
236
+ if (fileStructureType === FileStructureType.SINGLE_PAGE) {
209
237
  this.error(`Application files at ${resource.location} are in single page format, but the multi-page feature is enabled for your account. Please run superblocks migrate to convert your application to multi-page format and commit the changes before pulling.`);
210
238
  }
211
239
  else {
@@ -221,12 +249,12 @@ Would you like to also delete these resources from your filesystem?`,
221
249
  return;
222
250
  }
223
251
  ctx.writtenResources[resourceId] =
224
- await (0, version_control_1.writeMultiPageApplicationToDisk)(application, ctx.superblocksRootPath, ctx.featureFlags, resource.location, false);
252
+ await writeMultiPageApplicationToDisk(application, ctx.superblocksRootPath, ctx.featureFlags, resource.location, false);
225
253
  }
226
254
  task.title += `: done`;
227
255
  }
228
256
  catch (e) {
229
- if (e instanceof util_1.NotFoundError) {
257
+ if (e instanceof NotFoundError) {
230
258
  //NOTE(alex): today, branches are not shared between applications, so we can't pull from a branch that doesn't exist in the current application
231
259
  //once we have shared branches, we can remove this catch block
232
260
  task.title += `: not found in this branch. skipped`;
@@ -252,7 +280,7 @@ Would you like to also delete these resources from your filesystem?`,
252
280
  });
253
281
  task.title += `: fetched`;
254
282
  ctx.writtenResources[resourceId] =
255
- await (0, version_control_1.writeResourceToDisk)("BACKEND", resourceId, backend, ctx.superblocksRootPath, ctx.featureFlags, resource.location);
283
+ await writeResourceToDisk("BACKEND", resourceId, backend, ctx.superblocksRootPath, ctx.featureFlags, resource.location);
256
284
  task.title += `: done`;
257
285
  },
258
286
  });
@@ -275,23 +303,22 @@ Would you like to also delete these resources from your filesystem?`,
275
303
  return tasks;
276
304
  }
277
305
  async getResourceIdsToPull(ctx, task, resourcePath) {
278
- var _a, _b, _c, _d, _e;
279
306
  if (resourcePath) {
280
- for (const [resourceId, resource] of Object.entries((_b = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources) !== null && _b !== void 0 ? _b : {})) {
307
+ for (const [resourceId, resource] of Object.entries(ctx.existingSuperblocksRootConfig?.resources ?? {})) {
281
308
  if (resource.location === resourcePath) {
282
309
  return [resourceId];
283
310
  }
284
311
  }
285
312
  throw new Error(`No resource found with the given location: ${resourcePath}`);
286
313
  }
287
- const resourceConfig = await (0, util_1.getSuperblocksResourceConfigIfExists)();
314
+ const resourceConfig = await getSuperblocksResourceConfigIfExists();
288
315
  if (resourceConfig) {
289
316
  return [resourceConfig.id];
290
317
  }
291
318
  const choices = [];
292
319
  const initialSelections = [];
293
320
  let counter = 0;
294
- for (const [resourceId, resource] of Object.entries((_d = (_c = ctx.existingSuperblocksRootConfig) === null || _c === void 0 ? void 0 : _c.resources) !== null && _d !== void 0 ? _d : {})) {
321
+ for (const [resourceId, resource] of Object.entries(ctx.existingSuperblocksRootConfig?.resources ?? {})) {
295
322
  if (ctx.removedResourceIds.includes(resourceId)) {
296
323
  continue;
297
324
  }
@@ -299,7 +326,7 @@ Would you like to also delete these resources from your filesystem?`,
299
326
  name: resourceId,
300
327
  message: resource.location,
301
328
  });
302
- if (((_e = ctx.existingSuperblocksResourceConfig) === null || _e === void 0 ? void 0 : _e.id) === resourceId) {
329
+ if (ctx.existingSuperblocksResourceConfig?.id === resourceId) {
303
330
  initialSelections.push(counter);
304
331
  }
305
332
  counter++;
@@ -310,10 +337,10 @@ Would you like to also delete these resources from your filesystem?`,
310
337
  {
311
338
  type: "MultiSelect",
312
339
  name: "resourceIdsToPull",
313
- message: `Select resources to pull (${version_control_1.MULTI_SELECT_PROMPT_HELP})`,
340
+ message: `Select resources to pull (${MULTI_SELECT_PROMPT_HELP})`,
314
341
  choices: choices,
315
342
  initial: initialSelections,
316
- validate: version_control_1.atLeastOneSelection,
343
+ validate: atLeastOneSelection,
317
344
  prefix: "▸",
318
345
  indicator: "◉",
319
346
  },
@@ -321,38 +348,3 @@ Would you like to also delete these resources from your filesystem?`,
321
348
  return resourceIdsToPull;
322
349
  }
323
350
  }
324
- Pull.description = "Download objects from Superblocks and save them locally";
325
- Pull.examples = [
326
- "<%= config.bin %> <%= command.id %>",
327
- "<%= config.bin %> <%= command.id %> apps/my-app",
328
- "<%= config.bin %> <%= command.id %> apps/my-app -b feature-branch",
329
- "<%= config.bin %> <%= command.id %> apps/my-app -c commit-id",
330
- ];
331
- Pull.flags = {
332
- mode: core_1.Flags.string({
333
- char: "m",
334
- description: "Pull mode",
335
- options: Object.keys(version_control_1.modeFlagValuesMap),
336
- default: version_control_1.LATEST_EDITS_MODE,
337
- }),
338
- branch: core_1.Flags.string({
339
- char: "b",
340
- description: "Superblocks branch to pull from, the current git branch will be used by default",
341
- }),
342
- "commit-id": core_1.Flags.string({
343
- char: "c",
344
- description: "Superblocks commit id to pull, the live edit will be used by default",
345
- }),
346
- "skip-signing-verification": core_1.Flags.boolean({
347
- char: "s",
348
- description: "If true, signature verification for signing enabled organizations will be skipped.",
349
- default: false,
350
- }),
351
- };
352
- Pull.args = {
353
- resource_path: core_1.Args.string({
354
- description: "Superblocks resource location to pull (i.e. apps/my-app)",
355
- required: false,
356
- }),
357
- };
358
- exports.default = Pull;
@@ -0,0 +1,15 @@
1
+ import { AuthenticatedCommand } from "../common/authenticated-command.mjs";
2
+ export default class Push extends AuthenticatedCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ "skip-commit": import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ };
9
+ static args: {
10
+ resource_path: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
11
+ };
12
+ run(): Promise<void>;
13
+ private createTasks;
14
+ private getResourceIdsToPush;
15
+ }