Skip to content

Commit 78e9d95

Browse files
Update dependencies and improve publish command
1 parent 19516e0 commit 78e9d95

File tree

3 files changed

+1171
-576
lines changed

3 files changed

+1171
-576
lines changed

apps/commonality/package.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"lint:fix": "eslint . --fix"
4949
},
5050
"dependencies": {
51-
"@antfu/install-pkg": "^0.3.1",
51+
"@antfu/install-pkg": "^0.3.3",
5252
"@clack/prompts": "^0.7.0",
5353
"@sindresorhus/slugify": "^2.2.1",
5454
"boxen": "^7.1.1",
@@ -59,27 +59,27 @@
5959
"detect-indent": "^7.0.1",
6060
"find-up": "^6.3.0",
6161
"fs-extra": "^11.2.0",
62-
"get-port": "^7.0.0",
62+
"get-port": "^7.1.0",
6363
"git-branch": "^2.0.1",
6464
"globby": "^13.2.2",
65-
"import-meta-resolve": "^4.0.0",
65+
"import-meta-resolve": "^4.1.0",
6666
"ip": "^1.1.9",
6767
"jest-diff": "^29.7.0",
68-
"jiti": "^1.21.0",
69-
"ky": "^1.4.0",
68+
"jiti": "^1.21.6",
69+
"ky": "^1.5.0",
7070
"local-pkg": "^0.5.0",
7171
"lodash-es": "^4.17.21",
72-
"micromatch": "^4.0.5",
73-
"nanoid": "^5.0.6",
72+
"micromatch": "^4.0.7",
73+
"nanoid": "^5.0.7",
7474
"ora": "^7.0.1",
7575
"pathe": "^1.1.2",
76-
"pino": "^8.19.0",
76+
"pino": "^8.21.0",
7777
"prompts": "^2.4.2",
7878
"std-env": "^3.7.0",
7979
"strip-ansi": "^7.1.0",
80-
"update-notifier": "^7.0.0",
80+
"update-notifier": "^7.2.0",
8181
"wait-on": "^7.2.0",
82-
"yaml": "^2.3.4",
82+
"yaml": "^2.5.0",
8383
"zod": "^3.23.8"
8484
},
8585
"devDependencies": {
@@ -94,21 +94,22 @@
9494
"@commonalityco/utils-core": "workspace:*",
9595
"@commonalityco/utils-file": "workspace:*",
9696
"@commonalityco/utils-onboarding": "workspace:*",
97-
"@swc/core": "^1.4.2",
97+
"@swc/core": "^1.7.2",
9898
"@types/fs-extra": "^11.0.4",
99+
"@types/git-branch": "^2.0.5",
99100
"@types/ip": "^1.1.3",
100101
"@types/lodash-es": "^4.17.12",
101102
"@types/mock-fs": "^4.13.4",
102-
"@types/node": "^20.11.20",
103+
"@types/node": "^20.14.12",
103104
"@types/prompts": "^2.4.9",
104105
"@types/wait-on": "^5.3.4",
105106
"eslint-config-commonality": "workspace:*",
106107
"execa": "^8.0.1",
107108
"mock-fs": "^5.2.0",
108109
"npm-run-all": "^4.1.5",
109-
"rimraf": "^5.0.5",
110-
"tsup": "^8.0.2",
111-
"typescript": "^5.3.3",
112-
"vitest": "^2.0.2"
110+
"rimraf": "^5.0.9",
111+
"tsup": "^8.2.3",
112+
"typescript": "^5.5.4",
113+
"vitest": "^2.0.4"
113114
}
114115
}

apps/commonality/src/cli/commands/publish.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { getDependencies, getPackages } from '@commonalityco/data-packages';
1010
import ky, { HTTPError } from 'ky';
1111
import * as prompts from '@clack/prompts';
12+
import gitBranch from 'git-branch';
1213

1314
const command = new Command();
1415

@@ -22,7 +23,7 @@ export const publish = command
2223
'--api <apiUrl>',
2324
'The API URL to publish to',
2425
process.env.COMMONALITY_API_URL ??
25-
'http://app.commonality.co/api/v1/publish',
26+
'https://app.commonality.co/api/v1/publish',
2627
)
2728
.requiredOption(
2829
'--project <projectId>',
@@ -38,7 +39,7 @@ export const publish = command
3839
try {
3940
publishSpinner.start('Publishing snapshot...');
4041

41-
const { api, project, key } = options;
42+
const { api, project, key, verbose } = options;
4243

4344
const rootDirectory = await getRootDirectory();
4445
const blocks = await getPackages({ rootDirectory });
@@ -48,18 +49,23 @@ export const publish = command
4849
packages: blocks,
4950
});
5051
const dependencies = await getDependencies({ rootDirectory });
52+
5153
const data = {
5254
publishKey: key,
5355
projectId: project,
5456
codeowners,
5557
blocks,
5658
dependencies,
57-
gitBranch: '',
59+
gitBranch: await gitBranch(),
5860
} satisfies CreateSnapshotSchemaType;
5961

6062
const result = createSnapshotSchema.safeParse(data);
6163

6264
if (!result.success) {
65+
if (verbose) {
66+
console.error(result.error);
67+
}
68+
6369
publishSpinner.stop('Failed to publish snapshot');
6470
prompts.log.error('Invalid snapshot data: ' + result.error);
6571
return;
@@ -78,15 +84,28 @@ export const publish = command
7884
const errorJson = (await error.response.json()) as {
7985
message: string;
8086
};
87+
88+
if (verbose) {
89+
console.error(error);
90+
}
91+
8192
publishSpinner.stop('Failed to publish snapshot');
8293
prompts.log.error(errorJson.message);
8394
} else {
95+
if (verbose) {
96+
console.error(error);
97+
}
98+
8499
publishSpinner.stop('Failed to publish snapshot');
85100
}
86101

87102
process.exit(1);
88103
}
89-
} catch {
104+
} catch (error) {
105+
if (options.verbose) {
106+
console.error(error);
107+
}
108+
90109
publishSpinner.stop('Failed to publish snapshot');
91110
process.exit(1);
92111
}

0 commit comments

Comments
 (0)