Skip to content

Commit

Permalink
build: release @myparcel-do/shared
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Mar 13, 2024
1 parent 543dade commit a8fb9e3
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 46 deletions.
8 changes: 7 additions & 1 deletion apps/delivery-options/release.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-template-curly-in-string */
const path = require('node:path');
const {
addChangelogPlugin,
addCommitAnalyzerPlugin,
Expand All @@ -24,7 +25,12 @@ module.exports = {
/*
* Includes npm and git functionality
*/
'@myparcel-do/semantic-release-plugin',
[
'@myparcel-do/semantic-release-plugin',
{
additionalPackages: [path.resolve(__dirname, '../../libs/shared')],
},
],

addGitHubPlugin(),
],
Expand Down
6 changes: 3 additions & 3 deletions apps/delivery-options/vite-myparcel-lib.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {copyFileSync} from 'node:fs';
import {writeFileSync} from 'node:fs';
import dts from 'vite-plugin-dts';
import {mergeConfig, type UserConfig} from 'vite';
import {createViteConfig} from '@myparcel-do/build-vite';
Expand All @@ -15,8 +15,8 @@ export default createViteConfig((env) => {
entryRoot: 'src',
rollupTypes: true,
afterBuild: () => {
// To please publint, we need to copy the .d.ts file to .d.cts
copyFileSync('dist/index.d.ts', 'dist/index.d.cts');
// To please publint, we need to also have a .d.cts file
writeFileSync('dist/index.d.cts', "export * from './index';");
},
}),
],
Expand Down
2 changes: 2 additions & 0 deletions libs/semantic-release-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export type * from './types';

export {prepare} from './prepare';

export {publish} from './publish';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {type ContextWithNextRelease} from '../types';

export const updatePackageJsonVersions = async (context: ContextWithNextRelease): Promise<void> => {
const {cwd, env, logger, nextRelease} = context;
const pkg = await getPackageJson(context);
const pkg = await getPackageJson(context.cwd);

if (pkg?.name) {
const {version} = nextRelease;
Expand Down
9 changes: 5 additions & 4 deletions libs/semantic-release-plugin/src/publish/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {getPackageJson, hasErrors, throwIfHasErrors} from '../utils';
import {type PublishCmd} from '../types';
import {removeWorkspaceDependencies} from './removeWorkspaceDependencies';
import {publishNpmPackage} from './publishNpmPackage';
import {gitPush} from './gitPush';

export const publish: PublishCmd = async (pluginConfig, context) => {
const pkg = await getPackageJson(context);
const pkg = await getPackageJson(context.cwd);
const {logger} = context;

await gitPush(context);
Expand All @@ -15,9 +14,11 @@ export const publish: PublishCmd = async (pluginConfig, context) => {
return;
}

await removeWorkspaceDependencies(context);

if (!hasErrors()) {
for (const additionalPackage of pluginConfig.additionalPackages ?? []) {
await publishNpmPackage({...context, cwd: additionalPackage});
}

await publishNpmPackage(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {getChannel} from './getChannel';
export const publishNpmPackage = async (context: ContextWithNextRelease): Promise<void> => {
const {env, cwd, logger, nextRelease} = context;

const pkg = await getPackageJson(context);
const pkg = await getPackageJson(context.cwd);
const tag = getChannel(context.nextRelease.channel);

logger.log(`Publishing package ${pkg?.name}@${nextRelease.version} (${tag}) to NPM registry`);
Expand Down

This file was deleted.

6 changes: 5 additions & 1 deletion libs/semantic-release-plugin/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import {type DebugLogger} from 'node:util';

interface PluginConfig {
export interface PluginConfig {
/**
* Directories of additional packages to publish.
*/
additionalPackages?: string[];
npmPublish?: boolean;
pkgRoot?: string;
}
Expand Down
5 changes: 2 additions & 3 deletions libs/semantic-release-plugin/src/utils/getPackageJson.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {readPackage, type NormalizedPackageJson} from 'read-pkg';
import {type ContextWithNextRelease} from '../types';
import {addError, throwIfHasErrors} from './errorHandling';

let pkg: NormalizedPackageJson | undefined;

export const getPackageJson = async (context: ContextWithNextRelease): Promise<NormalizedPackageJson> => {
export const getPackageJson = async (cwd: string): Promise<NormalizedPackageJson> => {
try {
if (!pkg) {
pkg = await readPackage({cwd: context.cwd});
pkg = await readPackage({cwd});
}

if (!pkg?.name) {
Expand Down
1 change: 0 additions & 1 deletion libs/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@myparcel-do/shared",
"version": "6.0.0-beta.1",
"private": true,
"description": "",
"repository": {
"type": "git",
Expand Down

0 comments on commit a8fb9e3

Please sign in to comment.