Skip to content

Commit

Permalink
feat: change bundle-project to create-artifact (#463)
Browse files Browse the repository at this point in the history
Signed-off-by: hxtree <[email protected]>
Signed-off-by: Matthew Heroux <[email protected]>
  • Loading branch information
hxtree authored Oct 26, 2023
1 parent d1095db commit c9b5563
Show file tree
Hide file tree
Showing 31 changed files with 183 additions and 168 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/call-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# deploy project for pipeline
- name: rush build:project
run: node common/scripts/install-run-rush.js build:project
- name: rush artifact
run: node common/scripts/install-run-rush.js artifact

- uses: shallwefootball/s3-upload-action@master
name: Upload S3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/call-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
- name: rush build
run: node common/scripts/install-run-rush.js build

- name: rush build:project
run: node common/scripts/install-run-rush.js build:project
- name: rush artifact
run: node common/scripts/install-run-rush.js artifact

- name: Upload items to Github Release
uses: ncipollo/release-action@v1
Expand Down
4 changes: 4 additions & 0 deletions common/config/rush/browser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
"name": "@cats-cradle/constructs",
"allowedCategories": [ "apis", "category-ci-cd", "cicd", "rigs" ]
},
{
"name": "@cats-cradle/create-artifact",
"allowedCategories": [ "apis" ]
},
{
"name": "@cats-cradle/design-system",
"allowedCategories": [ "apis" ]
Expand Down
6 changes: 3 additions & 3 deletions common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
"allowWarningsInSuccessfulBuild": true
},
{
"name": "build:project",
"name": "artifact",
"commandKind": "bulk",
"summary": "Run build:project",
"description": "Run build:project to build all projects as individual dist separate from monorepo",
"summary": "Run artifact",
"description": "Run artifact to build all projects as individual dist separate from monorepo",
"safeForSimultaneousRushProcesses": false,
"ignoreMissingScript": true,
"ignoreDependencyOrder": true,
Expand Down
110 changes: 55 additions & 55 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/config/rush/repo-state.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "01c10a399f6b8ce48e7386351699f5e2b01027a0",
"pnpmShrinkwrapHash": "7ddb584b3c15b4c87912b9fb791be1094bae6c36",
"preferredVersionsHash": "8ae0ba5bd02ec9c5763773a15e27aee08a6567f6"
}
6 changes: 0 additions & 6 deletions platform/bundle-project/.eslintrc.js

This file was deleted.

11 changes: 11 additions & 0 deletions platform/create-artifact/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
extends: ['@cats-cradle/eslint-config/profile/base'],
parserOptions: {
tsconfigRootDir: __dirname,
},
rules: {
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/naming-convention': 'off',
'consistent-return': 'off',
},
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@cats-cradle/bundle-project",
"name": "@cats-cradle/create-artifact",
"entries": [
{
"version": "1.1.2",
"tag": "@cats-cradle/bundle-project_v1.1.2",
"tag": "@cats-cradle/create-artifact_v1.1.2",
"date": "Wed, 04 Oct 2023 03:44:49 GMT",
"comments": {
"patch": [
Expand All @@ -15,7 +15,7 @@
},
{
"version": "1.1.1",
"tag": "@cats-cradle/bundle-project_v1.1.1",
"tag": "@cats-cradle/create-artifact_v1.1.1",
"date": "Mon, 24 Apr 2023 03:48:09 GMT",
"comments": {
"patch": [
Expand All @@ -27,7 +27,7 @@
},
{
"version": "1.1.0",
"tag": "@cats-cradle/bundle-project_v1.1.0",
"tag": "@cats-cradle/create-artifact_v1.1.0",
"date": "Mon, 24 Apr 2023 02:39:45 GMT",
"comments": {
"minor": [
Expand All @@ -39,7 +39,7 @@
},
{
"version": "1.0.8",
"tag": "@cats-cradle/bundle-project_v1.0.8",
"tag": "@cats-cradle/create-artifact_v1.0.8",
"date": "Thu, 20 Apr 2023 15:41:51 GMT",
"comments": {
"patch": [
Expand All @@ -51,7 +51,7 @@
},
{
"version": "1.0.7",
"tag": "@cats-cradle/bundle-project_v1.0.7",
"tag": "@cats-cradle/create-artifact_v1.0.7",
"date": "Thu, 20 Apr 2023 03:22:16 GMT",
"comments": {
"patch": [
Expand All @@ -63,7 +63,7 @@
},
{
"version": "1.0.6",
"tag": "@cats-cradle/bundle-project_v1.0.6",
"tag": "@cats-cradle/create-artifact_v1.0.6",
"date": "Thu, 13 Apr 2023 13:12:14 GMT",
"comments": {
"patch": [
Expand All @@ -75,7 +75,7 @@
},
{
"version": "1.0.4",
"tag": "@cats-cradle/bundle-project_v1.0.4",
"tag": "@cats-cradle/create-artifact_v1.0.4",
"date": "Thu, 13 Apr 2023 05:30:55 GMT",
"comments": {
"patch": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Change Log - @cats-cradle/bundle-project
# Change Log - @cats-cradle/create-artifact

This log was last generated on Wed, 04 Oct 2023 03:44:49 GMT and should not be manually modified.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# @cats-cradle/bundle-project
# @cats-cradle/create-artifact

BundleProject is a tool for bundling a single PNPM workspace. It creates a copy
of the workspace, replaces the package.json `workspace:*` with the actual
versions, and compresses the project as a ZIP file.
create-artifact is a tool for bundling a single package into an artifact. It was
designed to help create small fast deployable projects.

It was designed for a monorepo that uses PNPM to help create small fast
deployable projects using AWS CDK in AWS CodePipelines.
## How it Works

In order for this to work properly each `workspace` dependency must be published
prior to services that use it being deployed.
create-artifact creates a copy of the workspace, replaces any dynamic
package.json `workspace:*` references with the actual versions, and compresses
the project as a ZIP file.

> **Note** In CI/CD pipelines make sure to publish each `workspace` dependency
> prior to services that use it being deployed.
## Usage

### Example in RushJS

For each project that will be compressed, add BundleProject as a dev dependency:
For each project that needs an artifact, add create-artifact as a dev
dependency:

```bash
# example of how to add dev dependency in RushJS
rush add --package @cats-cradle/bundle-project --dev
rush add --package @cats-cradle/create-artifact --dev
```

Add a script command to bundle your package to the project's package.json. Make
Expand All @@ -28,15 +31,15 @@ sure to replace `my-package-name` with the name of your package.
{
"name": "my-package-name",
"scripts": {
"build:project": "bundle-project my-package-name"
"artifact": "create-artifact my-package-name"
}
}
```

Run the script to bundle the project.

```bash
rushx build:project
rushx artifact
```

## Opinions
Expand All @@ -55,12 +58,12 @@ approach had several costly drawbacks:
required.
- It exponentially increases the amount of downloading and processing that needs
to be done within a CodePipeline. This in turn can create prolonged contract
varations between microservices when deploying multi service changes, which
variations between microservices when deploying multi service changes, which
can cause system errors.
- This expoententially increases disaster recovery time, as pipelines take
longer to ship code.
- This exponentially increases disaster recovery time, as pipelines take longer
to ship code.

Instead BundleProject was favored. It enables for a single dedicated Github CI
Instead create-artifact was favored. It enables for a single dedicated Github CI
build stage to individually bundle, compress each project changed (along with
workspace and non-workspace dependencies), and put the compress object in a S3
bucket. A CodePipeline is then triggered on each object put to deploy the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node
// dedicated bin file required due to https://github.com/microsoft/rushstack/issues/1100
require('../dist/bin-bundle-project.js');
require('../dist/bin-create-artifact.js');
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@cats-cradle/bundle-project",
"name": "@cats-cradle/create-artifact",
"version": "1.1.2",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -8,10 +8,10 @@
"dist"
],
"bin": {
"bundle-project": "bin/bundle-project"
"create-artifact": "bin/create-artifact"
},
"scripts": {
"bundle-project": "bin/bundle-project",
"create-artifact": "bin/create-artifact",
"build": "tsc && tsc-alias",
"build:all": "rush build -t .",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@cats-cradle/bundle-project",
"name": "@cats-cradle/create-artifact",
"version": "1.1.1",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist"],
"bin": {
"bundle-project": "bin/bundle-project"
"create-artifact": "bin/create-artifact"
},
"scripts": {
"bundle-project": "bin/bundle-project",
"create-artifact": "bin/create-artifact",
"build": "tsc && tsc-alias",
"build:all": "rush build -t .",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
Expand Down
Loading

0 comments on commit c9b5563

Please sign in to comment.