Skip to content

Commit

Permalink
Update dependencies and improve publish command
Browse files Browse the repository at this point in the history
  • Loading branch information
alec-chernicki committed Jul 26, 2024
1 parent 19516e0 commit 78e9d95
Show file tree
Hide file tree
Showing 3 changed files with 1,171 additions and 576 deletions.
33 changes: 17 additions & 16 deletions apps/commonality/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@antfu/install-pkg": "^0.3.1",
"@antfu/install-pkg": "^0.3.3",
"@clack/prompts": "^0.7.0",
"@sindresorhus/slugify": "^2.2.1",
"boxen": "^7.1.1",
Expand All @@ -59,27 +59,27 @@
"detect-indent": "^7.0.1",
"find-up": "^6.3.0",
"fs-extra": "^11.2.0",
"get-port": "^7.0.0",
"get-port": "^7.1.0",
"git-branch": "^2.0.1",
"globby": "^13.2.2",
"import-meta-resolve": "^4.0.0",
"import-meta-resolve": "^4.1.0",
"ip": "^1.1.9",
"jest-diff": "^29.7.0",
"jiti": "^1.21.0",
"ky": "^1.4.0",
"jiti": "^1.21.6",
"ky": "^1.5.0",
"local-pkg": "^0.5.0",
"lodash-es": "^4.17.21",
"micromatch": "^4.0.5",
"nanoid": "^5.0.6",
"micromatch": "^4.0.7",
"nanoid": "^5.0.7",
"ora": "^7.0.1",
"pathe": "^1.1.2",
"pino": "^8.19.0",
"pino": "^8.21.0",
"prompts": "^2.4.2",
"std-env": "^3.7.0",
"strip-ansi": "^7.1.0",
"update-notifier": "^7.0.0",
"update-notifier": "^7.2.0",
"wait-on": "^7.2.0",
"yaml": "^2.3.4",
"yaml": "^2.5.0",
"zod": "^3.23.8"
},
"devDependencies": {
Expand All @@ -94,21 +94,22 @@
"@commonalityco/utils-core": "workspace:*",
"@commonalityco/utils-file": "workspace:*",
"@commonalityco/utils-onboarding": "workspace:*",
"@swc/core": "^1.4.2",
"@swc/core": "^1.7.2",
"@types/fs-extra": "^11.0.4",
"@types/git-branch": "^2.0.5",
"@types/ip": "^1.1.3",
"@types/lodash-es": "^4.17.12",
"@types/mock-fs": "^4.13.4",
"@types/node": "^20.11.20",
"@types/node": "^20.14.12",
"@types/prompts": "^2.4.9",
"@types/wait-on": "^5.3.4",
"eslint-config-commonality": "workspace:*",
"execa": "^8.0.1",
"mock-fs": "^5.2.0",
"npm-run-all": "^4.1.5",
"rimraf": "^5.0.5",
"tsup": "^8.0.2",
"typescript": "^5.3.3",
"vitest": "^2.0.2"
"rimraf": "^5.0.9",
"tsup": "^8.2.3",
"typescript": "^5.5.4",
"vitest": "^2.0.4"
}
}
27 changes: 23 additions & 4 deletions apps/commonality/src/cli/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { getDependencies, getPackages } from '@commonalityco/data-packages';
import ky, { HTTPError } from 'ky';
import * as prompts from '@clack/prompts';
import gitBranch from 'git-branch';

const command = new Command();

Expand All @@ -22,7 +23,7 @@ export const publish = command
'--api <apiUrl>',
'The API URL to publish to',
process.env.COMMONALITY_API_URL ??
'http://app.commonality.co/api/v1/publish',
'https://app.commonality.co/api/v1/publish',
)
.requiredOption(
'--project <projectId>',
Expand All @@ -38,7 +39,7 @@ export const publish = command
try {
publishSpinner.start('Publishing snapshot...');

const { api, project, key } = options;
const { api, project, key, verbose } = options;

const rootDirectory = await getRootDirectory();
const blocks = await getPackages({ rootDirectory });
Expand All @@ -48,18 +49,23 @@ export const publish = command
packages: blocks,
});
const dependencies = await getDependencies({ rootDirectory });

const data = {
publishKey: key,
projectId: project,
codeowners,
blocks,
dependencies,
gitBranch: '',
gitBranch: await gitBranch(),
} satisfies CreateSnapshotSchemaType;

const result = createSnapshotSchema.safeParse(data);

if (!result.success) {
if (verbose) {
console.error(result.error);
}

publishSpinner.stop('Failed to publish snapshot');
prompts.log.error('Invalid snapshot data: ' + result.error);
return;
Expand All @@ -78,15 +84,28 @@ export const publish = command
const errorJson = (await error.response.json()) as {
message: string;
};

if (verbose) {
console.error(error);
}

publishSpinner.stop('Failed to publish snapshot');
prompts.log.error(errorJson.message);
} else {
if (verbose) {
console.error(error);
}

publishSpinner.stop('Failed to publish snapshot');
}

process.exit(1);
}
} catch {
} catch (error) {
if (options.verbose) {
console.error(error);
}

publishSpinner.stop('Failed to publish snapshot');
process.exit(1);
}
Expand Down
Loading

0 comments on commit 78e9d95

Please sign in to comment.