From 03fee060943f54da057c8d2f61abea0cb1701774 Mon Sep 17 00:00:00 2001 From: hxtree Date: Sat, 28 Oct 2023 02:48:30 +0000 Subject: [PATCH 1/5] feat: add bundler watch Signed-off-by: hxtree --- .../rush/browser-approved-packages.json | 4 + common/config/rush/pnpm-lock.yaml | 3 + common/config/rush/repo-state.json | 2 +- platform/bundlers/package.json | 3 +- .../src/__tests__/nestjs-bundler.test.ts | 69 +++++++++++--- .../__tests__/test-data/nestjs/src/index.ts | 2 +- platform/bundlers/src/bin-nestjs.ts | 9 +- platform/bundlers/src/index.ts | 2 +- .../bundlers/src/profiles/nestjs-bundler.ts | 90 ++++++++++++++----- 9 files changed, 142 insertions(+), 42 deletions(-) diff --git a/common/config/rush/browser-approved-packages.json b/common/config/rush/browser-approved-packages.json index caf749fe..5cf5917a 100644 --- a/common/config/rush/browser-approved-packages.json +++ b/common/config/rush/browser-approved-packages.json @@ -386,6 +386,10 @@ "name": "babel-plugin-prismjs", "allowedCategories": [ "apis" ] }, + { + "name": "chokidar", + "allowedCategories": [ "rigs" ] + }, { "name": "chrome-aws-lambda", "allowedCategories": [ "apis" ] diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 872eb70f..fc2ca765 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -568,6 +568,9 @@ importers: '@cats-cradle/base-nodejs': specifier: workspace:* version: link:../rigs/base-nodejs + chokidar: + specifier: ~3.5.3 + version: 3.5.3 commander: specifier: ~10.0.0 version: 10.0.0 diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index 0c48a024..259d533d 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "8c9243aa1c7fedfa20d02ca87c93357469e14692", + "pnpmShrinkwrapHash": "c1dce0c19a4eb476eb73dc80b6df2b2cd9d39a7d", "preferredVersionsHash": "8ae0ba5bd02ec9c5763773a15e27aee08a6567f6" } diff --git a/platform/bundlers/package.json b/platform/bundlers/package.json index a246f265..f4a1ffba 100644 --- a/platform/bundlers/package.json +++ b/platform/bundlers/package.json @@ -34,7 +34,8 @@ "@cats-cradle/base-nodejs": "workspace:*", "@anatine/esbuild-decorators": "~0.2.19", "commander": "~10.0.0", - "esbuild": "~0.17.5" + "esbuild": "~0.17.5", + "chokidar": "~3.5.3" }, "devDependencies": { "@types/jest": "29.5.5", diff --git a/platform/bundlers/src/__tests__/nestjs-bundler.test.ts b/platform/bundlers/src/__tests__/nestjs-bundler.test.ts index 699e4a9b..1a4ed89f 100644 --- a/platform/bundlers/src/__tests__/nestjs-bundler.test.ts +++ b/platform/bundlers/src/__tests__/nestjs-bundler.test.ts @@ -1,18 +1,65 @@ -import { rmSync, readFileSync } from 'fs'; +import { + existsSync, rmSync, readFileSync, writeFileSync, +} from 'fs'; import { join } from 'path'; -import { nestJsBundler } from '../profiles/nestjs-bundler'; +import { NestJsBundler } from '../profiles/nestjs-bundler'; + +function sleep(ms: number) { + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); +} + +describe('NestJsBundler', () => { + const distFolder = join(__dirname, 'test-data/nestjs/dist'); + const inputFilename = join(__dirname, 'test-data/nestjs/src/index.ts'); + const outputFilename = join(__dirname, 'test-data/nestjs/dist/index.js'); + + afterEach(async () => { + if (existsSync(outputFilename)) { + rmSync(distFolder, { + recursive: true, + force: true, + }); + } + writeFileSync(inputFilename, "console.log('tear down')"); + }); -describe('nestJsBundler', () => { it('should build src to dist', async () => { - rmSync('./dist', { recursive: true, force: true }); - const result = await nestJsBundler({ + const date = Date.now().toString(); + const contents = `console.log("modified ${date}");`; + writeFileSync(inputFilename, contents); + + const bundler = new NestJsBundler({ projectRoot: join(__dirname, 'test-data/nestjs'), + watch: false, }); - const file = readFileSync( - join(__dirname, 'test-data/nestjs/dist/index.js'), - 'utf-8', - ); - expect(result).toEqual(undefined); - expect(file).toContain('console.log("test");'); + await bundler.build(); + + const file = readFileSync(outputFilename, 'utf-8'); + expect(file).toContain(contents); }); + + it('should watch for file changes and rebuild', async () => { + const date = Date.now().toString(); + const contents = `console.log("modified ${date}");`; + + const bundler = new NestJsBundler({ + projectRoot: join(__dirname, 'test-data/nestjs'), + watch: true, + }); + + // wait for watch to init + await sleep(1000); + + writeFileSync(inputFilename, contents); + + // wait for watch to run + await sleep(1000); + + await bundler.close(); + + const file = readFileSync(outputFilename, 'utf-8'); + expect(file).toContain(contents); + }, 3000); }); diff --git a/platform/bundlers/src/__tests__/test-data/nestjs/src/index.ts b/platform/bundlers/src/__tests__/test-data/nestjs/src/index.ts index a2248efc..b46d41b9 100644 --- a/platform/bundlers/src/__tests__/test-data/nestjs/src/index.ts +++ b/platform/bundlers/src/__tests__/test-data/nestjs/src/index.ts @@ -1 +1 @@ -console.log('test'); +console.log('tear down'); diff --git a/platform/bundlers/src/bin-nestjs.ts b/platform/bundlers/src/bin-nestjs.ts index 4ba7b0fe..ea5bde38 100644 --- a/platform/bundlers/src/bin-nestjs.ts +++ b/platform/bundlers/src/bin-nestjs.ts @@ -1,7 +1,10 @@ #!/usr/bin/env node -import { join } from 'path'; -import { nestJsBundler } from './profiles/nestjs-bundler'; +import { NestJsBundler } from './profiles/nestjs-bundler'; const projectRoot = process.cwd(); +const watchMode = process.argv.includes('--watch'); -nestJsBundler({ projectRoot }); +new NestJsBundler({ + projectRoot, + watch: !!watchMode, +}); diff --git a/platform/bundlers/src/index.ts b/platform/bundlers/src/index.ts index 5765f3be..f65f7860 100644 --- a/platform/bundlers/src/index.ts +++ b/platform/bundlers/src/index.ts @@ -1 +1 @@ -export { nestJsBundler } from './profiles/nestjs-bundler'; +export { NestJsBundler } from './profiles/nestjs-bundler'; diff --git a/platform/bundlers/src/profiles/nestjs-bundler.ts b/platform/bundlers/src/profiles/nestjs-bundler.ts index 6d9ae653..30777030 100644 --- a/platform/bundlers/src/profiles/nestjs-bundler.ts +++ b/platform/bundlers/src/profiles/nestjs-bundler.ts @@ -1,22 +1,35 @@ import { build } from 'esbuild'; -import { join } from 'path'; +import { join, resolve } from 'path'; import { rmSync } from 'fs'; import { esbuildDecorators } from '@anatine/esbuild-decorators'; +import chokidar, { FSWatcher } from 'chokidar'; export interface NestJsBundlerOptions { projectRoot: string; + watch?: boolean; + timeout?: number; } -export async function nestJsBundler(options: NestJsBundlerOptions) { - const tsconfigPath = join(options.projectRoot, 'tsconfig.json'); - const entryPoint = join(options.projectRoot, 'src', 'index.ts'); - const outDir = join(options.projectRoot, 'dist'); +export class NestJsBundler { + options: NestJsBundlerOptions; - // remove previous bundle - rmSync(outDir, { recursive: true, force: true }); + tsConfigPath: string; - try { - const externalModules = [ + entryPoint: string; + + outDir: string; + + externalModules: string[]; + + watcher: FSWatcher; + + constructor(options: NestJsBundlerOptions) { + this.options = options; + + this.tsConfigPath = join(options.projectRoot, 'tsconfig.json'); + this.entryPoint = join(options.projectRoot, 'src', 'index.ts'); + this.outDir = join(options.projectRoot, 'dist'); + this.externalModules = [ // nestjs 'express', 'reflect-metadata', @@ -40,20 +53,49 @@ export async function nestJsBundler(options: NestJsBundlerOptions) { 'puppeteer-core', ]; - await build({ - entryPoints: [entryPoint], - outdir: outDir, - bundle: true, - platform: 'node', - target: 'es2021', - external: externalModules, - tsconfig: tsconfigPath, - plugins: [esbuildDecorators()], - }); - - console.log('Build succeeded!'); - } catch (e) { - console.error(`Build failed: ${e}`); - process.exit(1); + rmSync(this.outDir, { recursive: true, force: true }); + + if (options.watch) { + const watchDirectory = join(options.projectRoot, 'src'); + + console.log(`Running in watch mode on ${watchDirectory}`); + + this.watcher = chokidar + .watch(watchDirectory) + .on('change', async (event, path) => { + await build({ + entryPoints: [this.entryPoint], + outdir: this.outDir, + bundle: true, + platform: 'node', + target: 'es2021', + external: this.externalModules, + tsconfig: this.tsConfigPath, + plugins: [esbuildDecorators()], + }); + }); + } + } + + async close() { + await this.watcher.close(); + } + + async build() { + try { + await build({ + entryPoints: [this.entryPoint], + outdir: this.outDir, + bundle: true, + platform: 'node', + target: 'es2021', + external: this.externalModules, + tsconfig: this.tsConfigPath, + plugins: [esbuildDecorators()], + }); + } catch (e) { + console.error(`Build failed: ${e}`); + process.exit(1); + } } } From cf84b6cc85aefd799e8ce50be583941357a7c47f Mon Sep 17 00:00:00 2001 From: hxtree Date: Sat, 28 Oct 2023 02:50:06 +0000 Subject: [PATCH 2/5] chore: bump version Signed-off-by: hxtree --- platform/bundlers/CHANGELOG.json | 12 ++++++++++++ platform/bundlers/CHANGELOG.md | 9 ++++++++- platform/bundlers/package.json | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/platform/bundlers/CHANGELOG.json b/platform/bundlers/CHANGELOG.json index 91b2ea9a..13e30265 100644 --- a/platform/bundlers/CHANGELOG.json +++ b/platform/bundlers/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@cats-cradle/bundlers", "entries": [ + { + "version": "0.1.0", + "tag": "@cats-cradle/bundlers_v0.1.0", + "date": "Sat, 28 Oct 2023 02:49:38 GMT", + "comments": { + "minor": [ + { + "comment": "Add support for --watch flag" + } + ] + } + }, { "version": "0.0.5", "tag": "@cats-cradle/bundlers_v0.0.5", diff --git a/platform/bundlers/CHANGELOG.md b/platform/bundlers/CHANGELOG.md index 1f40c5a3..9fa3b270 100644 --- a/platform/bundlers/CHANGELOG.md +++ b/platform/bundlers/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @cats-cradle/bundlers -This log was last generated on Sat, 14 Oct 2023 22:49:51 GMT and should not be manually modified. +This log was last generated on Sat, 28 Oct 2023 02:49:38 GMT and should not be manually modified. + +## 0.1.0 +Sat, 28 Oct 2023 02:49:38 GMT + +### Minor changes + +- Add support for --watch flag ## 0.0.5 Sat, 14 Oct 2023 22:49:51 GMT diff --git a/platform/bundlers/package.json b/platform/bundlers/package.json index f4a1ffba..79c4a4f3 100644 --- a/platform/bundlers/package.json +++ b/platform/bundlers/package.json @@ -5,7 +5,7 @@ "nestjs-bundler": "./dist/bin-nestjs.js" }, "main": "./dist/index.js", - "version": "0.0.5", + "version": "0.1.0", "repository": { "type": "git", "url": "git+https://github.com/hxtree/cats-cradle.git" From f64a5c99635fe49cca2cd63e6ab720cfc4cdbf99 Mon Sep 17 00:00:00 2001 From: hxtree Date: Sat, 28 Oct 2023 02:59:58 +0000 Subject: [PATCH 3/5] feat: rename bundler to create-bundle Signed-off-by: hxtree --- common/config/rush/pnpm-lock.yaml | 109 ++++++++++-------- common/config/rush/repo-state.json | 2 +- .../{bundlers => create-bundle}/.eslintrc.js | 0 .../CHANGELOG.json | 0 .../{bundlers => create-bundle}/CHANGELOG.md | 0 .../{bundlers => create-bundle}/LICENSE.md | 0 .../{bundlers => create-bundle}/README.md | 11 +- .../jest.config.js | 0 .../{bundlers => create-bundle}/package.json | 4 +- .../src/__tests__/nestjs-bundler.test.ts | 0 .../__tests__/test-data/nestjs/src/index.ts | 0 .../__tests__/test-data/nestjs/tsconfig.json | 0 .../src/create-bundle-bin.ts} | 2 + .../{bundlers => create-bundle}/src/index.ts | 0 .../src/profiles/nestjs-bundler.ts | 0 .../{bundlers => create-bundle}/tsconfig.json | 0 rush.json | 31 ++--- 17 files changed, 81 insertions(+), 78 deletions(-) rename platform/{bundlers => create-bundle}/.eslintrc.js (100%) rename platform/{bundlers => create-bundle}/CHANGELOG.json (100%) rename platform/{bundlers => create-bundle}/CHANGELOG.md (100%) rename platform/{bundlers => create-bundle}/LICENSE.md (100%) rename platform/{bundlers => create-bundle}/README.md (64%) rename platform/{bundlers => create-bundle}/jest.config.js (100%) rename platform/{bundlers => create-bundle}/package.json (92%) rename platform/{bundlers => create-bundle}/src/__tests__/nestjs-bundler.test.ts (100%) rename platform/{bundlers => create-bundle}/src/__tests__/test-data/nestjs/src/index.ts (100%) rename platform/{bundlers => create-bundle}/src/__tests__/test-data/nestjs/tsconfig.json (100%) rename platform/{bundlers/src/bin-nestjs.ts => create-bundle/src/create-bundle-bin.ts} (75%) rename platform/{bundlers => create-bundle}/src/index.ts (100%) rename platform/{bundlers => create-bundle}/src/profiles/nestjs-bundler.ts (100%) rename platform/{bundlers => create-bundle}/tsconfig.json (100%) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index fc2ca765..50badab1 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -560,49 +560,6 @@ importers: specifier: 5.1.3 version: 5.1.3 - ../../platform/bundlers: - dependencies: - '@anatine/esbuild-decorators': - specifier: ~0.2.19 - version: 0.2.19(esbuild@0.17.5) - '@cats-cradle/base-nodejs': - specifier: workspace:* - version: link:../rigs/base-nodejs - chokidar: - specifier: ~3.5.3 - version: 3.5.3 - commander: - specifier: ~10.0.0 - version: 10.0.0 - esbuild: - specifier: ~0.17.5 - version: 0.17.5 - devDependencies: - '@cats-cradle/eslint-config': - specifier: 1.0.6 - version: 1.0.6 - '@types/jest': - specifier: 29.5.5 - version: 29.5.5 - '@types/node': - specifier: 20.8.2 - version: 20.8.2 - eslint: - specifier: 8.44.0 - version: 8.44.0 - jest: - specifier: 29.7.0 - version: 29.7.0(@types/node@20.8.2)(ts-node@10.9.1) - ts-jest: - specifier: 29.1.1 - version: 29.1.1(@babel/core@7.22.20)(esbuild@0.17.5)(jest@29.7.0)(typescript@5.1.3) - ts-node: - specifier: 10.9.1 - version: 10.9.1(@swc/core@1.3.89)(@types/node@20.8.2)(typescript@5.1.3) - typescript: - specifier: 5.1.3 - version: 5.1.3 - ../../platform/constructs: dependencies: '@nestjs/common': @@ -767,6 +724,49 @@ importers: specifier: 5.1.3 version: 5.1.3 + ../../platform/create-bundle: + dependencies: + '@anatine/esbuild-decorators': + specifier: ~0.2.19 + version: 0.2.19(esbuild@0.17.5) + '@cats-cradle/base-nodejs': + specifier: workspace:* + version: link:../rigs/base-nodejs + chokidar: + specifier: ~3.5.3 + version: 3.5.3 + commander: + specifier: ~10.0.0 + version: 10.0.0 + esbuild: + specifier: ~0.17.5 + version: 0.17.5 + devDependencies: + '@cats-cradle/eslint-config': + specifier: 1.0.6 + version: 1.0.6 + '@types/jest': + specifier: 29.5.5 + version: 29.5.5 + '@types/node': + specifier: 20.8.2 + version: 20.8.2 + eslint: + specifier: 8.44.0 + version: 8.44.0 + jest: + specifier: 29.7.0 + version: 29.7.0(@types/node@20.8.2)(ts-node@10.9.1) + ts-jest: + specifier: 29.1.1 + version: 29.1.1(@babel/core@7.22.20)(esbuild@0.17.5)(jest@29.7.0)(typescript@5.1.3) + ts-node: + specifier: 10.9.1 + version: 10.9.1(@swc/core@1.3.89)(@types/node@20.8.2)(typescript@5.1.3) + typescript: + specifier: 5.1.3 + version: 5.1.3 + ../../platform/eslint-config: dependencies: '@rushstack/eslint-config': @@ -2606,12 +2606,21 @@ packages: '@jridgewell/gen-mapping': 0.3.3 '@jridgewell/trace-mapping': 0.3.19 + /@anatine/esbuild-decorators@0.2.19(esbuild@0.17.19): + resolution: {integrity: sha512-pyj6ULyMacyzpDqlnbS2OCkOqxcVgk8IqiTMRJ5CrsF8Yl1azvlX/AM6xWR8UzHKUYDlWOw5mOpos3+7KKR0Lw==} + peerDependencies: + esbuild: ~0.14.29 + dependencies: + esbuild: 0.17.19 + dev: true + /@anatine/esbuild-decorators@0.2.19(esbuild@0.17.5): resolution: {integrity: sha512-pyj6ULyMacyzpDqlnbS2OCkOqxcVgk8IqiTMRJ5CrsF8Yl1azvlX/AM6xWR8UzHKUYDlWOw5mOpos3+7KKR0Lw==} peerDependencies: esbuild: ~0.14.29 dependencies: esbuild: 0.17.5 + dev: false /@angular-devkit/core@14.0.5: resolution: {integrity: sha512-/CUGi6QLwh79FvsOY7M+1LQL3asZsbQW/WBd5f1iu5y7TLNqCwo+wOb0ZXLDNPw45vYBxFajtt3ob3U7qx3jNg==} @@ -7289,11 +7298,11 @@ packages: /@bcoe/v8-coverage@0.2.3: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} - /@cats-cradle/base-nodejs@1.0.3(@babel/core@7.22.20)(@types/node@20.8.2)(esbuild@0.17.5)(ts-node@10.9.1)(typescript@5.1.3): + /@cats-cradle/base-nodejs@1.0.3(@babel/core@7.22.20)(@types/node@20.8.2)(esbuild@0.17.19)(ts-node@10.9.1)(typescript@5.1.3): resolution: {integrity: sha512-t/dwRt45XCOFNU84HBIy200Y7avUKwycQDSJXXB7Yi5AHAmZJnsrbKFpbbllpE3s79D7uZCQxywWFoiKSi/PqQ==} dependencies: jest: 29.5.0(@types/node@20.8.2)(ts-node@10.9.1) - ts-jest: 29.1.0(@babel/core@7.22.20)(esbuild@0.17.5)(jest@29.5.0)(typescript@5.1.3) + ts-jest: 29.1.0(@babel/core@7.22.20)(esbuild@0.17.19)(jest@29.5.0)(typescript@5.1.3) transitivePeerDependencies: - '@babel/core' - '@jest/types' @@ -7311,10 +7320,10 @@ packages: resolution: {integrity: sha512-DREu86GTzX+ZY0VXg9zZVMQ0xqeRUb6jBGnoyNE8Ndu3OOiUbsIHQqqAvcs6x5XOy8uaMyuO8As1TPyVFO0xlg==} hasBin: true dependencies: - '@anatine/esbuild-decorators': 0.2.19(esbuild@0.17.5) - '@cats-cradle/base-nodejs': 1.0.3(@babel/core@7.22.20)(@types/node@20.8.2)(esbuild@0.17.5)(ts-node@10.9.1)(typescript@5.1.3) + '@anatine/esbuild-decorators': 0.2.19(esbuild@0.17.19) + '@cats-cradle/base-nodejs': 1.0.3(@babel/core@7.22.20)(@types/node@20.8.2)(esbuild@0.17.19)(ts-node@10.9.1)(typescript@5.1.3) commander: 10.0.1 - esbuild: 0.17.5 + esbuild: 0.17.19 transitivePeerDependencies: - '@babel/core' - '@jest/types' @@ -29221,7 +29230,7 @@ packages: yargs-parser: 18.1.3 dev: true - /ts-jest@29.1.0(@babel/core@7.22.20)(esbuild@0.17.5)(jest@29.5.0)(typescript@5.1.3): + /ts-jest@29.1.0(@babel/core@7.22.20)(esbuild@0.17.19)(jest@29.5.0)(typescript@5.1.3): resolution: {integrity: sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -29244,7 +29253,7 @@ packages: dependencies: '@babel/core': 7.22.20 bs-logger: 0.2.6 - esbuild: 0.17.5 + esbuild: 0.17.19 fast-json-stable-stringify: 2.1.0 jest: 29.5.0(@types/node@20.8.2)(ts-node@10.9.1) jest-util: 29.7.0 diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index 259d533d..12f993df 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "c1dce0c19a4eb476eb73dc80b6df2b2cd9d39a7d", + "pnpmShrinkwrapHash": "418ba6bcdb56844db65e8a29967843e698b30e80", "preferredVersionsHash": "8ae0ba5bd02ec9c5763773a15e27aee08a6567f6" } diff --git a/platform/bundlers/.eslintrc.js b/platform/create-bundle/.eslintrc.js similarity index 100% rename from platform/bundlers/.eslintrc.js rename to platform/create-bundle/.eslintrc.js diff --git a/platform/bundlers/CHANGELOG.json b/platform/create-bundle/CHANGELOG.json similarity index 100% rename from platform/bundlers/CHANGELOG.json rename to platform/create-bundle/CHANGELOG.json diff --git a/platform/bundlers/CHANGELOG.md b/platform/create-bundle/CHANGELOG.md similarity index 100% rename from platform/bundlers/CHANGELOG.md rename to platform/create-bundle/CHANGELOG.md diff --git a/platform/bundlers/LICENSE.md b/platform/create-bundle/LICENSE.md similarity index 100% rename from platform/bundlers/LICENSE.md rename to platform/create-bundle/LICENSE.md diff --git a/platform/bundlers/README.md b/platform/create-bundle/README.md similarity index 64% rename from platform/bundlers/README.md rename to platform/create-bundle/README.md index d403e4b4..b49cd666 100644 --- a/platform/bundlers/README.md +++ b/platform/create-bundle/README.md @@ -1,14 +1,14 @@ -# @cats-cradle/bundlers +# @cats-cradle/create-bundle This package contains various bundler profiles. The bundlers bundle another -projects source code to make it ready for deployment. +projects source code to make it ready for distribution. ## Usage Install bundler as devDependency: ```bash -npm install @cats-cradle/bundlers --dev +npm install @cats-cradle/create-bundle --dev ``` Call the binary from within your package.json @@ -17,8 +17,9 @@ Call the binary from within your package.json { "name": "your-package", "scripts": { - "build": "nestjs-bundler", - "cdk:deploy": "nestjs-bundler && cdk deploy" + "build": "create-bundle", + "build:watch": "create-bundle --watch", + "cdk:deploy": "create-bundle && cdk deploy" } } ``` diff --git a/platform/bundlers/jest.config.js b/platform/create-bundle/jest.config.js similarity index 100% rename from platform/bundlers/jest.config.js rename to platform/create-bundle/jest.config.js diff --git a/platform/bundlers/package.json b/platform/create-bundle/package.json similarity index 92% rename from platform/bundlers/package.json rename to platform/create-bundle/package.json index 79c4a4f3..97e0f9ed 100644 --- a/platform/bundlers/package.json +++ b/platform/create-bundle/package.json @@ -1,8 +1,8 @@ { - "name": "@cats-cradle/bundlers", + "name": "@cats-cradle/create-bundle", "license": "MIT", "bin": { - "nestjs-bundler": "./dist/bin-nestjs.js" + "create-bundle": "./dist/create-bundle-bin.js" }, "main": "./dist/index.js", "version": "0.1.0", diff --git a/platform/bundlers/src/__tests__/nestjs-bundler.test.ts b/platform/create-bundle/src/__tests__/nestjs-bundler.test.ts similarity index 100% rename from platform/bundlers/src/__tests__/nestjs-bundler.test.ts rename to platform/create-bundle/src/__tests__/nestjs-bundler.test.ts diff --git a/platform/bundlers/src/__tests__/test-data/nestjs/src/index.ts b/platform/create-bundle/src/__tests__/test-data/nestjs/src/index.ts similarity index 100% rename from platform/bundlers/src/__tests__/test-data/nestjs/src/index.ts rename to platform/create-bundle/src/__tests__/test-data/nestjs/src/index.ts diff --git a/platform/bundlers/src/__tests__/test-data/nestjs/tsconfig.json b/platform/create-bundle/src/__tests__/test-data/nestjs/tsconfig.json similarity index 100% rename from platform/bundlers/src/__tests__/test-data/nestjs/tsconfig.json rename to platform/create-bundle/src/__tests__/test-data/nestjs/tsconfig.json diff --git a/platform/bundlers/src/bin-nestjs.ts b/platform/create-bundle/src/create-bundle-bin.ts similarity index 75% rename from platform/bundlers/src/bin-nestjs.ts rename to platform/create-bundle/src/create-bundle-bin.ts index ea5bde38..c136cd54 100644 --- a/platform/bundlers/src/bin-nestjs.ts +++ b/platform/create-bundle/src/create-bundle-bin.ts @@ -4,6 +4,8 @@ import { NestJsBundler } from './profiles/nestjs-bundler'; const projectRoot = process.cwd(); const watchMode = process.argv.includes('--watch'); +// TODO add support for other bundle profiles based on flags as necessary + new NestJsBundler({ projectRoot, watch: !!watchMode, diff --git a/platform/bundlers/src/index.ts b/platform/create-bundle/src/index.ts similarity index 100% rename from platform/bundlers/src/index.ts rename to platform/create-bundle/src/index.ts diff --git a/platform/bundlers/src/profiles/nestjs-bundler.ts b/platform/create-bundle/src/profiles/nestjs-bundler.ts similarity index 100% rename from platform/bundlers/src/profiles/nestjs-bundler.ts rename to platform/create-bundle/src/profiles/nestjs-bundler.ts diff --git a/platform/bundlers/tsconfig.json b/platform/create-bundle/tsconfig.json similarity index 100% rename from platform/bundlers/tsconfig.json rename to platform/create-bundle/tsconfig.json diff --git a/rush.json b/rush.json index 8225d162..68323c22 100644 --- a/rush.json +++ b/rush.json @@ -41,8 +41,8 @@ ], "projects": [ { - "packageName": "@cats-cradle/bundlers", - "projectFolder": "platform/bundlers", + "packageName": "@cats-cradle/create-bundle", + "projectFolder": "platform/create-bundle", "reviewCategory": "rigs", "decoupledLocalDependencies": ["@cats-cradle/eslint-config"], "tags": [], @@ -180,8 +180,7 @@ "decoupledLocalDependencies": [ "@cats-cradle/validation-schemas", "@cats-cradle/eslint-config", - "@cats-cradle/create-artifact", - "@cats-cradle/bundlers" + "@cats-cradle/create-artifact" ], "tags": [], "shouldPublish": true @@ -193,8 +192,7 @@ "decoupledLocalDependencies": [ "@cats-cradle/validation-schemas", "@cats-cradle/eslint-config", - "@cats-cradle/create-artifact", - "@cats-cradle/bundlers" + "@cats-cradle/create-artifact" ], "tags": [] }, @@ -205,8 +203,7 @@ "decoupledLocalDependencies": [ "@cats-cradle/validation-schemas", "@cats-cradle/eslint-config", - "@cats-cradle/create-artifact", - "@cats-cradle/bundlers" + "@cats-cradle/create-artifact" ], "tags": [] }, @@ -238,8 +235,7 @@ "decoupledLocalDependencies": [ "@cats-cradle/validation-schemas", "@cats-cradle/eslint-config", - "@cats-cradle/create-artifact", - "@cats-cradle/bundlers" + "@cats-cradle/create-artifact" ], "tags": ["deploy-app"], "shouldPublish": true @@ -251,8 +247,7 @@ "decoupledLocalDependencies": [ "@cats-cradle/eslint-config", "@cats-cradle/nestjs-modules", - "@cats-cradle/create-artifact", - "@cats-cradle/bundlers" + "@cats-cradle/create-artifact" ], "tags": ["deploy-app"] }, @@ -262,8 +257,7 @@ "reviewCategory": "apis", "decoupledLocalDependencies": [ "@cats-cradle/eslint-config", - "@cats-cradle/create-artifact", - "@cats-cradle/bundlers" + "@cats-cradle/create-artifact" ], "tags": ["deploy-app"] }, @@ -274,8 +268,7 @@ "decoupledLocalDependencies": [ "@cats-cradle/validation-schemas", "@cats-cradle/eslint-config", - "@cats-cradle/create-artifact", - "@cats-cradle/bundlers" + "@cats-cradle/create-artifact" ], "tags": ["deploy-app"], "shouldPublish": true @@ -287,8 +280,7 @@ "decoupledLocalDependencies": [ "@cats-cradle/eslint-config", "@cats-cradle/nestjs-modules", - "@cats-cradle/create-artifact", - "@cats-cradle/bundlers" + "@cats-cradle/create-artifact" ], "tags": ["deploy-app"], "shouldPublish": true @@ -300,8 +292,7 @@ "decoupledLocalDependencies": [ "@cats-cradle/eslint-config", "@cats-cradle/nestjs-modules", - "@cats-cradle/create-artifact", - "@cats-cradle/bundlers" + "@cats-cradle/create-artifact" ], "tags": ["deploy-app"] } From adfe84ade149b1a21e3220f8171f4be1c8de2f4f Mon Sep 17 00:00:00 2001 From: hxtree Date: Sat, 28 Oct 2023 03:02:48 +0000 Subject: [PATCH 4/5] chore: bump versions Signed-off-by: hxtree --- platform/create-bundle/CHANGELOG.json | 19 ++++++++++++++++++- platform/create-bundle/CHANGELOG.md | 15 +++++++++++++-- platform/create-bundle/package.json | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/platform/create-bundle/CHANGELOG.json b/platform/create-bundle/CHANGELOG.json index 13e30265..0b417117 100644 --- a/platform/create-bundle/CHANGELOG.json +++ b/platform/create-bundle/CHANGELOG.json @@ -1,6 +1,23 @@ { - "name": "@cats-cradle/bundlers", + "name": "@cats-cradle/create-bundle", "entries": [ + { + "version": "1.0.0", + "tag": "@cats-cradle/create-bundle_v1.0.0", + "date": "Sat, 28 Oct 2023 03:02:33 GMT", + "comments": { + "major": [ + { + "comment": "rename package from bundlers to create-bundle" + } + ], + "patch": [ + { + "comment": "rename package from bundlers to create-bundle" + } + ] + } + }, { "version": "0.1.0", "tag": "@cats-cradle/bundlers_v0.1.0", diff --git a/platform/create-bundle/CHANGELOG.md b/platform/create-bundle/CHANGELOG.md index 9fa3b270..83d6913d 100644 --- a/platform/create-bundle/CHANGELOG.md +++ b/platform/create-bundle/CHANGELOG.md @@ -1,6 +1,17 @@ -# Change Log - @cats-cradle/bundlers +# Change Log - @cats-cradle/create-bundle -This log was last generated on Sat, 28 Oct 2023 02:49:38 GMT and should not be manually modified. +This log was last generated on Sat, 28 Oct 2023 03:02:33 GMT and should not be manually modified. + +## 1.0.0 +Sat, 28 Oct 2023 03:02:33 GMT + +### Breaking changes + +- rename package from bundlers to create-bundle + +### Patches + +- rename package from bundlers to create-bundle ## 0.1.0 Sat, 28 Oct 2023 02:49:38 GMT diff --git a/platform/create-bundle/package.json b/platform/create-bundle/package.json index 97e0f9ed..cb93fcdd 100644 --- a/platform/create-bundle/package.json +++ b/platform/create-bundle/package.json @@ -5,7 +5,7 @@ "create-bundle": "./dist/create-bundle-bin.js" }, "main": "./dist/index.js", - "version": "0.1.0", + "version": "1.0.0", "repository": { "type": "git", "url": "git+https://github.com/hxtree/cats-cradle.git" From 41de08e89459b634cecc79dac1bd036cad8a16c9 Mon Sep 17 00:00:00 2001 From: hxtree Date: Sat, 28 Oct 2023 03:08:32 +0000 Subject: [PATCH 5/5] feat: update release verbage to explain difference between service and package publishing Signed-off-by: hxtree --- .github/workflows/call-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/call-release.yml b/.github/workflows/call-release.yml index e9ff6262..443a6e08 100644 --- a/.github/workflows/call-release.yml +++ b/.github/workflows/call-release.yml @@ -57,7 +57,8 @@ jobs: body: | # New Release: [@cats-cradle ${{ github.ref_name }}](https://www.npmjs.com/search?q=%40cats-cradle), - We're pleased to share our latest release, which comprises multiple zip files, each housing a distinct, deploy-ready project from @cats-cradle. Within each package, you'll find the project's code and Infrastructure as Code (IaC) authored in AWS CDK v2 for streamlined deployment. + We're pleased to share our latest services release, which comprises multiple zip files, each housing a distinct, deploy-ready project from @cats-cradle. Within each package, you'll find the project's code and Infrastructure as Code (IaC) authored in AWS CDK v2 for streamlined deployment. Although each package is maintained primarily for the game, most stable packages + We release a multitude of packages independently of our services. Each package is individually published on [NPM](https://www.npmjs.com/search?q=%40cats-cradle) when any changes are made. We warmly invite you to delve into the contents of this release, offer your valuable feedback, and actively engage in our project on GitHub. Your contributions and active participation are fundamental to our ongoing efforts to enhance and refine our offerings. artifacts: 'common/temp/dist/*.zip'