Skip to content

Commit

Permalink
Release script (#53)
Browse files Browse the repository at this point in the history
* scripts(tools-scripts): ๐Ÿ› ๏ธ basic release script
* release(nx): ๐Ÿ”– Release nx-plugin-vite@0.1.0
* scripts(tools-scripts): ๐Ÿ› ๏ธ release scripts
  • Loading branch information
linbudu599 authored Sep 20, 2021
1 parent c72a7ea commit e320fa6
Show file tree
Hide file tree
Showing 12 changed files with 300 additions and 59 deletions.
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspaces-experimental true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"dep-graph": "nx dep-graph",
"cli": "ts-node --transpile-only ./scripts/cli.ts",
"commit": "git add -A && git-cz",
"cz": "git add -A && git-cz --type release --scope nx --non-interactive --subject='r r r'",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs",
"docs:serve": "vuepress serve docs"
Expand Down
8 changes: 4 additions & 4 deletions packages/nx-plugin-vite/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# nx-plugin-vite

This library was generated with [Nx](https://nx.dev).
Nx plugin integration with [Vite](https://vitejs.dev/).

## Running unit tests

Run `nx test nx-plugin-vite` to execute the unit tests via [Jest](https://jestjs.io).
- [Documentation](https://nx-plugins.netlify.app/vite/)
- [GitHub Repo](https://github.com/LinbuduLab/nx-plugins)
- [Author](https://github.com/linbudu599)
2 changes: 1 addition & 1 deletion packages/nx-plugin-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nx-plugin-vite",
"version": "0.0.1",
"version": "0.1.0",
"main": "dist/src/index.js",
"scripts": {
"release": "release-it",
Expand Down
2 changes: 2 additions & 0 deletions scripts/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useSortConfiguration from './sort-configuration';
import useCollectPackageDeps from './collect-deps';
import useInitPackage from './init-package';
import useCreatePlayground from './create-playground';
import useReleaseProject from './release';

const cli = cac('nx-plugin');

Expand All @@ -14,6 +15,7 @@ useSortConfiguration(cli);
useCollectPackageDeps(cli);
useInitPackage(cli);
useCreatePlayground(cli);
useReleaseProject(cli);

cli.help();
cli.parse();
6 changes: 3 additions & 3 deletions scripts/collect-deps/collect-dep-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import jsonfile from 'jsonfile';
import pacote from 'pacote';
import { allPackages } from '../utils/packages';
import { readPackagesWithVersion } from '../utils/read-packages';
import { readWorkspacePackagesWithVersion } from '../utils/read-packages';

export async function collectDepsVersion(deps: string[]) {
const depsInfoWithVersion: Record<string, string> = {};
Expand All @@ -21,8 +21,8 @@ export function collectDepsVersionFromProjectPackage(deps: string[]) {
allPackages.includes(dep)
);

const packagesWithVersion = readPackagesWithVersion().filter((pair) =>
filteredDeps.includes(pair.project)
const packagesWithVersion = readWorkspacePackagesWithVersion().filter(
(pair) => filteredDeps.includes(pair.project)
);

const packageVersionRecord: Record<string, string> = {};
Expand Down
32 changes: 15 additions & 17 deletions scripts/collect-deps/index.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
import { CAC } from 'cac';
import consola from 'consola';
import { selectMultiProjects, selectScope } from '../utils/select-project';
import { availablePackages } from '../utils/packages';
import { selectMultiProjects } from '../utils/select-project';
import { allPackages, availablePackages } from '../utils/packages';
import { ALL_FLAG } from './constants';
import { handler } from './handler';

export default function useCollectPackageDeps(cli: CAC) {
cli
.command('collect', 'Collect package deps', {
.command('collect [project]', 'Collect package deps', {
allowUnknownOptions: true,
})
.alias('c')
.action(async () => {
// const scope = await selectScope();
.action(async (project?: string) => {
if (project && allPackages.includes(project)) {
handler(project);
return;
}

const projects = await selectMultiProjects(
[ALL_FLAG],
'Choose project you want to collect dependencies for'
// scope
);

// single one
if (projects.length === 1 && !projects.includes(ALL_FLAG)) {
handler(projects[0]);
// multi
} else if (projects.length >= 1 && !projects.includes(ALL_FLAG)) {
for (const projectItem of projects) {
handler(projectItem);
}
// all
} else if (projects.includes(ALL_FLAG)) {
if (projects.includes(ALL_FLAG)) {
for (const projectItem of availablePackages) {
handler(projectItem);
}
return;
}

for (const projectItem of projects) {
handler(projectItem);
}
});
}
Loading

0 comments on commit e320fa6

Please sign in to comment.