@superblocksteam/cli 1.2.1 → 1.3.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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ $ npm install -g @superblocksteam/cli
12
12
  $ superblocks COMMAND
13
13
  running command...
14
14
  $ superblocks (--version)
15
- @superblocksteam/cli/1.2.1 linux-x64 node-v18.18.2
15
+ @superblocksteam/cli/1.3.0 linux-x64 node-v18.18.2
16
16
  $ superblocks --help [COMMAND]
17
17
  USAGE
18
18
  $ superblocks COMMAND
@@ -7,7 +7,7 @@
7
7
  "lint:fix": "npx eslint . --fix"
8
8
  },
9
9
  "dependencies": {
10
- "@superblocksteam/custom-components": "1.2.1",
10
+ "@superblocksteam/custom-components": "1.3.0",
11
11
  "react": "^18",
12
12
  "react-dom": "^18"
13
13
  },
@@ -11,7 +11,6 @@ const colorette_1 = require("colorette");
11
11
  const fs = tslib_1.__importStar(require("fs-extra"));
12
12
  const vite_1 = require("vite");
13
13
  const authenticated_command_1 = require("../../common/authenticated-command");
14
- const version_control_1 = require("../../common/version-control");
15
14
  class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
16
15
  async run() {
17
16
  const { flags } = await this.parse(Upload);
@@ -23,7 +22,7 @@ class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
23
22
  exit: 1,
24
23
  });
25
24
  }
26
- const branch = flags.branch || (await (0, version_control_1.getCurrentGitBranchIfGit)());
25
+ const { branchName } = await this.validateApplicationGitSetup(util_1.ComponentEvent.UPLOAD, flags.branch);
27
26
  const headers = {
28
27
  [util_1.COMPONENT_EVENT_HEADER]: util_1.ComponentEvent.REGISTER,
29
28
  };
@@ -93,7 +92,7 @@ class Upload extends authenticated_command_1.AuthenticatedApplicationCommand {
93
92
  ];
94
93
  await walkThroughDirectory(".", fileRelativePaths, excluded);
95
94
  this.log(fileRelativePaths.join("\n"));
96
- await this.getSdk().uploadComponents(this.applicationConfig.id, configs, fileRelativePaths, branch);
95
+ await this.getSdk().uploadComponents(this.applicationConfig.id, configs, fileRelativePaths, branchName);
97
96
  core_1.ux.action.stop();
98
97
  }
99
98
  catch (e) {
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from "vite";
2
2
  import { AuthenticatedApplicationCommand } from "../../common/authenticated-command";
3
- export declare function healthEndpointMiddleware(): Plugin;
3
+ export declare function healthEndpointMiddleware(getBranch: () => Promise<string | null>): Plugin;
4
4
  export default class Watch extends AuthenticatedApplicationCommand {
5
5
  static description: string;
6
6
  run(): Promise<void>;
@@ -10,20 +10,14 @@ const colorette_1 = require("colorette");
10
10
  const vite_1 = require("vite");
11
11
  const authenticated_command_1 = require("../../common/authenticated-command");
12
12
  const version_control_1 = require("../../common/version-control");
13
- function healthEndpointMiddleware() {
13
+ function healthEndpointMiddleware(getBranch) {
14
14
  return {
15
15
  name: "health-endpoint-middleware",
16
16
  configureServer: (server) => {
17
17
  server.middlewares.use("/health", async (req, res) => {
18
- let branch;
19
- try {
20
- branch = await (0, version_control_1.getCurrentGitBranchIfGit)();
21
- }
22
- catch (e) {
23
- branch = null;
24
- }
25
- const gitState = branch
26
- ? { active: true, branch }
18
+ const branchName = await getBranch();
19
+ const gitState = branchName
20
+ ? { active: true, branch: branchName }
27
21
  : { active: false };
28
22
  res.setHeader("Cache-Control", "no-cache");
29
23
  res.setHeader("Content-Type", "application/json");
@@ -50,10 +44,33 @@ class Watch extends authenticated_command_1.AuthenticatedApplicationCommand {
50
44
  this.log();
51
45
  const editModeUrl = new URL(await this.getEditModeUrl());
52
46
  editModeUrl.searchParams.set("devMode", "true");
53
- const branch = await (0, version_control_1.getCurrentGitBranchIfGit)();
54
- if (branch) {
55
- editModeUrl.searchParams.set("branch", branch);
47
+ const { branchName, localBranchName } = await this.validateApplicationGitSetup(util_1.ComponentEvent.REGISTER);
48
+ if (branchName) {
49
+ editModeUrl.searchParams.set("branch", branchName);
56
50
  }
51
+ // note: the local branch name can differ from the upstream branch name used in SB, so we need to track both
52
+ let lastBranchName = branchName;
53
+ let lastLocalBranchName = localBranchName;
54
+ const getBranch = async () => {
55
+ let curLocalBranchName;
56
+ try {
57
+ curLocalBranchName = await (0, version_control_1.getCurrentGitBranchIfGit)();
58
+ }
59
+ catch (e) {
60
+ curLocalBranchName = null;
61
+ }
62
+ if (curLocalBranchName === lastLocalBranchName) {
63
+ // the quick check (which avoids API calls) indicates that the branch hasn't changed, so return the last known value
64
+ return lastBranchName;
65
+ }
66
+ else {
67
+ // the quick check indicates that the branch has changed, so we need to make an API call to validate the new branch
68
+ const { branchName, localBranchName } = await this.validateApplicationGitSetup(util_1.ComponentEvent.REGISTER);
69
+ lastBranchName = branchName;
70
+ lastLocalBranchName = localBranchName;
71
+ return branchName;
72
+ }
73
+ };
57
74
  const port = 3002;
58
75
  const viteLogger = (0, vite_1.createLogger)();
59
76
  viteLogger.info = (message) => {
@@ -82,9 +99,9 @@ class Watch extends authenticated_command_1.AuthenticatedApplicationCommand {
82
99
  },
83
100
  customLogger: viteLogger,
84
101
  plugins: [
85
- healthEndpointMiddleware(),
102
+ healthEndpointMiddleware(getBranch),
86
103
  (0, plugin_react_1.default)(),
87
- (0, vite_custom_component_reload_plugin_1.appendHotReloadEventPlugin)(version_control_1.getCurrentGitBranchIfGit),
104
+ (0, vite_custom_component_reload_plugin_1.appendHotReloadEventPlugin)(getBranch),
88
105
  (0, react_shim_1.injectReactVersionsPlugin)(),
89
106
  ],
90
107
  });
@@ -38,8 +38,9 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
38
38
  {
39
39
  title: "Checking for existing git repository...",
40
40
  task: async (ctx) => {
41
+ ctx.branchToPullFrom = new Map();
41
42
  try {
42
- ctx.pullFromBranchName =
43
+ ctx.localBranchName =
43
44
  branch || (await (0, version_control_1.getCurrentGitBranchIfGit)()) || version_control_1.DEFAULT_BRANCH;
44
45
  }
45
46
  catch (e) {
@@ -58,8 +59,6 @@ class Pull extends authenticated_command_1.AuthenticatedCommand {
58
59
  try {
59
60
  await this.getSdk().fetchApplication({
60
61
  applicationId: resourceId,
61
- //NOTE(alex): using default branch since we assume that the resource is deleted if it's deleted from the default branch
62
- branch: version_control_1.DEFAULT_BRANCH,
63
62
  });
64
63
  }
65
64
  catch (error) {
@@ -123,18 +122,45 @@ Would you like to also delete these resources from your filesystem?`,
123
122
  },
124
123
  {
125
124
  task: async (ctx, task) => {
126
- var _a;
127
- task.title = `Pulling resources from branch ${ctx.pullFromBranchName}...`;
125
+ task.title = `Determining what resources to pull...`;
126
+ ctx.resourceIdsToPull = await this.getResourceIdsToPull(ctx, task, resourcePath);
127
+ },
128
+ },
129
+ {
130
+ task: async (ctx, task) => {
131
+ var _a, _b;
132
+ task.title = `Validating git configuration...`;
133
+ const subtasks = [];
134
+ for (const resourceId of ctx.resourceIdsToPull) {
135
+ const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
136
+ const resourceTitle = `${((_b = resource.resourceType) !== null && _b !== void 0 ? _b : "").toLowerCase()} ${resourceId}`;
137
+ subtasks.push({
138
+ title: `Checking ${resourceTitle}...`,
139
+ task: async () => {
140
+ const { branchName } = await this.validateGitSetup(resource === null || resource === void 0 ? void 0 : resource.resourceType, resourceId, util_1.ComponentEvent.PULL, ctx.localBranchName);
141
+ ctx.branchToPullFrom.set(resourceId, branchName);
142
+ },
143
+ });
144
+ }
145
+ return task.newListr(subtasks, {
146
+ concurrent: true,
147
+ });
148
+ },
149
+ },
150
+ {
151
+ task: async (ctx, task) => {
152
+ var _a, _b;
153
+ task.title = `Pulling resources from branch ${ctx.localBranchName}...`;
128
154
  const viewMode = await (0, version_control_1.getMode)(task, mode);
129
- const resourceIdsToPull = await this.getResourceIdsToPull(ctx, task, resourcePath);
130
155
  const subtasks = [];
131
156
  const superblocksRootPath = node_path_1.default.resolve(node_path_1.default.dirname(ctx.superblocksRootConfigPath), "..");
132
- for (const resourceId of resourceIdsToPull) {
157
+ for (const resourceId of ctx.resourceIdsToPull) {
133
158
  const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
159
+ const branchName = (_b = ctx.branchToPullFrom.get(resourceId)) !== null && _b !== void 0 ? _b : ctx.localBranchName;
134
160
  switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
135
161
  case "APPLICATION": {
136
162
  subtasks.push({
137
- title: `Pulling application ${resource.location} from branch ${ctx.pullFromBranchName}...`,
163
+ title: `Pulling application ${resource.location} from branch ${branchName}...`,
138
164
  task: async (_ctx, task) => {
139
165
  const headers = {
140
166
  [util_1.COMPONENT_EVENT_HEADER]: util_1.ComponentEvent.PULL,
@@ -142,7 +168,7 @@ Would you like to also delete these resources from your filesystem?`,
142
168
  try {
143
169
  const application = await this.getSdk().fetchApplicationWithComponents({
144
170
  applicationId: resourceId,
145
- branch: ctx.pullFromBranchName,
171
+ branch: branchName,
146
172
  viewMode,
147
173
  headers,
148
174
  });
@@ -39,10 +39,11 @@ class Push extends authenticated_command_1.AuthenticatedCommand {
39
39
  {
40
40
  title: "Checking for existing git repository...",
41
41
  task: async (ctx) => {
42
+ ctx.branchToPushTo = new Map();
42
43
  try {
43
- ctx.pushToBranchName =
44
+ ctx.localBranchName =
44
45
  branch || (await (0, version_control_1.getCurrentGitBranchIfGit)()) || version_control_1.DEFAULT_BRANCH;
45
- [ctx.headCommitId, ctx.headCommitMessage] = await (0, version_control_1.getHeadCommit)(ctx.pushToBranchName);
46
+ [ctx.headCommitId, ctx.headCommitMessage] = await (0, version_control_1.getHeadCommit)(ctx.localBranchName);
46
47
  }
47
48
  catch (e) {
48
49
  this.error(`Failed to check for existing git repository: ${e.message}. Please make sure to clone or initialize a git repository.`);
@@ -64,8 +65,6 @@ class Push extends authenticated_command_1.AuthenticatedCommand {
64
65
  try {
65
66
  await this.getSdk().fetchApplication({
66
67
  applicationId: resourceId,
67
- //NOTE(alex): using default branch since we assume that the resource is deleted if it's deleted from the default branch
68
- branch: version_control_1.DEFAULT_BRANCH,
69
68
  });
70
69
  }
71
70
  catch (error) {
@@ -127,20 +126,48 @@ Would you like to also delete these resources from your filesystem?`,
127
126
  }
128
127
  },
129
128
  },
129
+ {
130
+ task: async (ctx, task) => {
131
+ task.title = `Determining what resources to push...`;
132
+ ctx.resourceIdsToPush = await this.getResourceIdsToPush(ctx, task, resourceName);
133
+ },
134
+ },
135
+ {
136
+ task: async (ctx, task) => {
137
+ var _a, _b;
138
+ task.title = `Validating git configuration...`;
139
+ const subtasks = [];
140
+ for (const resourceId of ctx.resourceIdsToPush) {
141
+ const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
142
+ // for user messages:
143
+ const resourceTitle = `${((_b = resource.resourceType) !== null && _b !== void 0 ? _b : "").toLowerCase()} ${resourceId}`;
144
+ subtasks.push({
145
+ title: `Checking ${resourceTitle}...`,
146
+ task: async () => {
147
+ const { branchName } = await this.validateGitSetup(resource === null || resource === void 0 ? void 0 : resource.resourceType, resourceId, util_1.ComponentEvent.PUSH, ctx.localBranchName);
148
+ ctx.branchToPushTo.set(resourceId, branchName);
149
+ },
150
+ });
151
+ }
152
+ return task.newListr(subtasks, {
153
+ concurrent: true,
154
+ });
155
+ },
156
+ },
130
157
  {
131
158
  task: async (ctx, task) => {
132
159
  var _a;
133
- task.title = `Pushing resources to branch ${ctx.pushToBranchName}...`;
134
- const resourceIdsToPush = await this.getResourceIdsToPush(ctx, task, resourceName);
160
+ task.title = `Pushing resources to branch ${ctx.localBranchName}...`;
135
161
  const subtasks = [];
136
162
  const superblocksRootPath = node_path_1.default.resolve(node_path_1.default.dirname(ctx.superblocksRootConfigPath), "..");
137
- for (const resourceId of resourceIdsToPush) {
163
+ for (const resourceId of ctx.resourceIdsToPush) {
138
164
  const resource = (_a = ctx.existingSuperblocksRootConfig) === null || _a === void 0 ? void 0 : _a.resources[resourceId];
139
165
  switch (resource === null || resource === void 0 ? void 0 : resource.resourceType) {
140
166
  case "APPLICATION": {
141
167
  subtasks.push({
142
168
  title: `Pushing application ${resource.location}...`,
143
169
  task: async (_ctx, task) => {
170
+ var _a;
144
171
  const applicationConfig = {
145
172
  ...(await (0, version_control_1.readApplicationFromDisk)(superblocksRootPath, resource.location)),
146
173
  commitId: ctx.headCommitId,
@@ -151,7 +178,7 @@ Would you like to also delete these resources from your filesystem?`,
151
178
  await this.getSdk().pushApplication({
152
179
  applicationId: resourceId,
153
180
  applicationConfig,
154
- branch: ctx.pushToBranchName,
181
+ branch: (_a = ctx.branchToPushTo.get(resourceId)) !== null && _a !== void 0 ? _a : ctx.localBranchName,
155
182
  });
156
183
  }
157
184
  catch (error) {
@@ -1,9 +1,13 @@
1
1
  import { Command } from "@oclif/core";
2
2
  import { SuperblocksSdk } from "@superblocksteam/sdk";
3
- import { SuperblocksApplicationConfig } from "@superblocksteam/util";
3
+ import { SuperblocksApplicationConfig, ComponentEvent, SuperblocksResourceType } from "@superblocksteam/util";
4
4
  export declare abstract class AuthenticatedCommand extends Command {
5
5
  private sdk;
6
6
  protected init(): Promise<void>;
7
+ protected validateGitSetup(resourceType: SuperblocksResourceType, resourceId: string, event: ComponentEvent, overrideLocalBranch?: string, injectedHeaders?: Record<string, string>): Promise<{
8
+ branchName: string | null;
9
+ localBranchName: string | null;
10
+ }>;
7
11
  protected getBaseUrl(): Promise<string>;
8
12
  protected getSdk(): SuperblocksSdk;
9
13
  protected runAutomatedDotfileUpdates(): Promise<void>;
@@ -12,5 +16,9 @@ export declare abstract class AuthenticatedApplicationCommand extends Authentica
12
16
  applicationConfig: SuperblocksApplicationConfig;
13
17
  protected getEditModeUrl(): Promise<string>;
14
18
  protected init(): Promise<void>;
19
+ protected validateApplicationGitSetup(event: ComponentEvent, overrideLocalBranch?: string, injectedHeaders?: Record<string, string>): Promise<{
20
+ branchName: string | null;
21
+ localBranchName: string | null;
22
+ }>;
15
23
  protected registerComponents(injectedHeaders?: Record<string, string>): Promise<Record<string, any> | undefined>;
16
24
  }
@@ -29,6 +29,24 @@ class AuthenticatedCommand extends core_1.Command {
29
29
  this.error("Please run 'superblocks login' first", { exit: 1 });
30
30
  }
31
31
  }
32
+ async validateGitSetup(resourceType, resourceId, event, overrideLocalBranch, injectedHeaders) {
33
+ const localGitRepoState = await (0, version_control_1.getLocalGitRepoState)(overrideLocalBranch);
34
+ let branchName;
35
+ switch (resourceType) {
36
+ case "APPLICATION": {
37
+ ({ branchName } = await this.getSdk().validateGitSetup(resourceId, resourceType, event, localGitRepoState, injectedHeaders));
38
+ break;
39
+ }
40
+ default:
41
+ throw new Error(`Unsupported resource type: ${resourceType}`);
42
+ }
43
+ return {
44
+ branchName,
45
+ localBranchName: localGitRepoState.status === "IN_A_BRANCH"
46
+ ? localGitRepoState.localBranchName
47
+ : null,
48
+ };
49
+ }
32
50
  async getBaseUrl() {
33
51
  var _a;
34
52
  const result = await (0, util_1.getLocalTokenWithUrlIfExists)();
@@ -124,12 +142,12 @@ class AuthenticatedApplicationCommand extends AuthenticatedCommand {
124
142
  exit: 1,
125
143
  });
126
144
  }
145
+ const { branchName } = await this.validateApplicationGitSetup(util_1.ComponentEvent.INIT);
127
146
  core_1.ux.action.start("Checking application...");
128
147
  try {
129
- const branch = (await (0, version_control_1.getCurrentGitBranchIfGit)()) || version_control_1.DEFAULT_BRANCH;
130
148
  const application = await this.getSdk().fetchApplication({
131
149
  applicationId: this.applicationConfig.id,
132
- branch: branch,
150
+ branch: branchName !== null && branchName !== void 0 ? branchName : version_control_1.DEFAULT_BRANCH,
133
151
  });
134
152
  core_1.ux.action.stop();
135
153
  if ((_b = (_a = application === null || application === void 0 ? void 0 : application.application) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.cliVersion) {
@@ -144,6 +162,9 @@ class AuthenticatedApplicationCommand extends AuthenticatedCommand {
144
162
  this.warn(`Could not read the application from Superblocks: ${e.message}`);
145
163
  }
146
164
  }
165
+ async validateApplicationGitSetup(event, overrideLocalBranch, injectedHeaders) {
166
+ return this.validateGitSetup("APPLICATION", this.applicationConfig.id, event, overrideLocalBranch, injectedHeaders);
167
+ }
147
168
  async registerComponents(injectedHeaders) {
148
169
  var _a;
149
170
  core_1.ux.action.start("Checking CLI version compatibility...");
@@ -193,8 +214,8 @@ ${(0, colorette_1.cyan)("superblocks migrate")}`);
193
214
  core_1.ux.action.stop();
194
215
  try {
195
216
  core_1.ux.action.start("Registering components...");
196
- const branch = await (0, version_control_1.getCurrentGitBranchIfGit)();
197
- await this.getSdk().registerComponents(this.applicationConfig.id, configs, branch, injectedHeaders);
217
+ const { branchName } = await this.validateApplicationGitSetup(util_1.ComponentEvent.REGISTER);
218
+ await this.getSdk().registerComponents(this.applicationConfig.id, configs, branchName, injectedHeaders);
198
219
  core_1.ux.action.stop();
199
220
  }
200
221
  catch (e) {
@@ -1,4 +1,5 @@
1
1
  import { ApplicationWrapper, ViewMode } from "@superblocksteam/sdk";
2
+ import { LocalGitRepoState } from "@superblocksteam/util";
2
3
  import { VersionedResourceConfig } from "@superblocksteam/util";
3
4
  export declare const LATEST_EDITS_MODE = "latest-edits";
4
5
  export declare const MOST_RECENT_COMMIT_MODE = "most-recent-commit";
@@ -15,6 +16,7 @@ export declare function writeResourceToDisk(resourceType: string, resourceId: st
15
16
  export declare function removeResourceFromDisk(resourceLocation: string): Promise<void>;
16
17
  export declare function getMode(task: any, mode: ModeFlag): Promise<ViewMode>;
17
18
  export declare function sortByKey(obj: unknown): unknown;
19
+ export declare function getLocalGitRepoState(overrideLocalBranch?: string): Promise<LocalGitRepoState>;
18
20
  /**
19
21
  * Returns the current git branch, or undefined if not in a git repo
20
22
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isGitRepoDirty = exports.getHeadCommit = exports.getCurrentGitBranch = exports.getCurrentGitBranchIfGit = exports.sortByKey = exports.getMode = exports.removeResourceFromDisk = exports.writeResourceToDisk = exports.readApplicationFromDisk = exports.atLeastOneSelection = exports.MULTI_SELECT_PROMPT_HELP = exports.SELECT_PROMPT_HELP = exports.modeFlagToViewMode = exports.modeFlagValuesMap = exports.DEFAULT_BRANCH = exports.DEPLOYED_MODE = exports.MOST_RECENT_COMMIT_MODE = exports.LATEST_EDITS_MODE = void 0;
3
+ exports.isGitRepoDirty = exports.getHeadCommit = exports.getCurrentGitBranch = exports.getCurrentGitBranchIfGit = exports.getLocalGitRepoState = exports.sortByKey = exports.getMode = exports.removeResourceFromDisk = exports.writeResourceToDisk = exports.readApplicationFromDisk = exports.atLeastOneSelection = exports.MULTI_SELECT_PROMPT_HELP = exports.SELECT_PROMPT_HELP = exports.modeFlagToViewMode = exports.modeFlagValuesMap = exports.DEFAULT_BRANCH = exports.DEPLOYED_MODE = exports.MOST_RECENT_COMMIT_MODE = exports.LATEST_EDITS_MODE = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const https = tslib_1.__importStar(require("https"));
6
6
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
@@ -264,6 +264,56 @@ function sortByKey(obj) {
264
264
  return obj;
265
265
  }
266
266
  exports.sortByKey = sortByKey;
267
+ async function getLocalGitRepoState(overrideLocalBranch) {
268
+ var _a, _b, _c;
269
+ const git = (0, simple_git_1.simpleGit)();
270
+ let status;
271
+ try {
272
+ status = await git.status();
273
+ }
274
+ catch {
275
+ return { status: "NO_GIT" };
276
+ }
277
+ let localBranchName;
278
+ if (overrideLocalBranch) {
279
+ const branches = await git.branch();
280
+ if (!branches.all.includes(overrideLocalBranch)) {
281
+ throw new Error(`There is no branch named ${overrideLocalBranch}`);
282
+ }
283
+ localBranchName = overrideLocalBranch;
284
+ }
285
+ else {
286
+ if (status.detached || !status.current) {
287
+ return { status: "DETACHED" };
288
+ }
289
+ localBranchName = status.current;
290
+ }
291
+ const remoteName = (_a = (await git.getConfig(`branch.${localBranchName}.remote`))) === null || _a === void 0 ? void 0 : _a.value;
292
+ if (!remoteName) {
293
+ return { status: "IN_A_BRANCH", localBranchName };
294
+ }
295
+ const remoteFetchUrl = (_b = (await git.getConfig(`remote.${remoteName}.url`))) === null || _b === void 0 ? void 0 : _b.value;
296
+ if (!remoteFetchUrl) {
297
+ return { status: "IN_A_BRANCH", localBranchName };
298
+ }
299
+ const remotePushUrl = (_c = (await git.getConfig(`remote.${remoteName}.pushurl`))) === null || _c === void 0 ? void 0 : _c.value;
300
+ let upstreamBranchName = (await git.revparse(["--abbrev-ref", "--symbolic-full-name", "@{u}"])).split("\n", 1)[0];
301
+ if (upstreamBranchName.startsWith(`${remoteName}/`)) {
302
+ // `upstreamBranchName` is in the form `$remoteName/$branchName`, so we need to remove the `$remoteName/` part
303
+ upstreamBranchName = upstreamBranchName.substring(remoteName.length + 1);
304
+ }
305
+ return {
306
+ status: "IN_A_BRANCH",
307
+ localBranchName,
308
+ upstream: {
309
+ branchName: upstreamBranchName,
310
+ remoteName,
311
+ url: remoteFetchUrl,
312
+ pushUrl: remotePushUrl,
313
+ },
314
+ };
315
+ }
316
+ exports.getLocalGitRepoState = getLocalGitRepoState;
267
317
  /**
268
318
  * Returns the current git branch, or undefined if not in a git repo
269
319
  */
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.1",
2
+ "version": "1.3.0",
3
3
  "commands": {
4
4
  "init": {
5
5
  "id": "init",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/cli",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Official Superblocks CLI",
5
5
  "bin": {
6
6
  "superblocks": "bin/run"
@@ -18,11 +18,11 @@
18
18
  "@oclif/core": "^2.11.7",
19
19
  "@oclif/plugin-help": "^5.2.16",
20
20
  "@oclif/plugin-plugins": "^3.1.10",
21
- "@superblocksteam/css-plugin": "1.2.1",
22
- "@superblocksteam/react-shim": "1.2.1",
23
- "@superblocksteam/sdk": "1.2.1",
24
- "@superblocksteam/util": "1.2.1",
25
- "@superblocksteam/vite-custom-component-reload-plugin": "1.2.1",
21
+ "@superblocksteam/css-plugin": "1.3.0",
22
+ "@superblocksteam/react-shim": "1.3.0",
23
+ "@superblocksteam/sdk": "1.3.0",
24
+ "@superblocksteam/util": "1.3.0",
25
+ "@superblocksteam/vite-custom-component-reload-plugin": "1.3.0",
26
26
  "@vitejs/plugin-react": "^4.1.0",
27
27
  "colorette": "^2.0.19",
28
28
  "enquirer": "^2.3.6",