Skip to content

Commit 57996e8

Browse files
authored
feat(cli): CATALYST-246 create-catalyst login, create env, scaffold project (#474)
* feat(cli): CATALYST-246 create-catalyst login, create env, scaffold project * fix integration test
1 parent 00e0bd8 commit 57996e8

23 files changed

+1791
-103
lines changed

.github/workflows/cli-integration.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Create Catalyst CLI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
types: [opened, synchronize]
8+
merge_group:
9+
types: [checks_requested]
10+
11+
jobs:
12+
integration-tests:
13+
name: Integration Tests
14+
15+
runs-on: ubuntu-latest
16+
17+
env:
18+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
19+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
20+
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
21+
BIGCOMMERCE_STORE_HASH: ${{ secrets.BIGCOMMERCE_STORE_HASH }}
22+
BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN: ${{ secrets.BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN }}
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@main
27+
with:
28+
fetch-depth: 2
29+
30+
- uses: pnpm/action-setup@v2
31+
32+
- name: Use Node.js
33+
uses: actions/setup-node@main
34+
with:
35+
node-version-file: ".nvmrc"
36+
cache: "pnpm"
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile
40+
41+
- name: Build CLI
42+
run: pnpm build
43+
working-directory: packages/create-catalyst
44+
45+
- name: Run CLI
46+
run: |
47+
node dist/index.js \
48+
--ghRef ${{ github.sha }} \
49+
--projectDir ${{ runner.temp }} \
50+
--projectName catalyst-integration-test \
51+
--channelId 1 \
52+
--accessToken some_access_token \
53+
--storeHash ${{ secrets.BIGCOMMERCE_STORE_HASH }} \
54+
--customerImpersonationToken ${{ secrets.BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN }}
55+
working-directory: packages/create-catalyst

.github/workflows/cli-unit.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Create Catalyst CLI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
types: [opened, synchronize]
8+
merge_group:
9+
types: [checks_requested]
10+
11+
jobs:
12+
unit-tests:
13+
name: Unit Tests
14+
15+
runs-on: ubuntu-latest
16+
17+
env:
18+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
19+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
20+
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
21+
BIGCOMMERCE_STORE_HASH: ${{ secrets.BIGCOMMERCE_STORE_HASH }}
22+
BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN: ${{ secrets.BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN }}
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@main
27+
with:
28+
fetch-depth: 2
29+
30+
- uses: pnpm/action-setup@v2
31+
32+
- name: Use Node.js
33+
uses: actions/setup-node@main
34+
with:
35+
node-version-file: ".nvmrc"
36+
cache: "pnpm"
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile
40+
41+
- name: Run Tests
42+
run: pnpm test
43+
working-directory: packages/create-catalyst

packages/create-catalyst/.eslintrc.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const config = {
66
extends: ['@bigcommerce/catalyst/base', '@bigcommerce/catalyst/prettier'],
77
rules: {
88
'no-console': 'off',
9+
'import/no-named-as-default': 'off',
10+
'@typescript-eslint/naming-convention': 'off',
911
},
1012
ignorePatterns: ['/dist/**'],
1113
};

packages/create-catalyst/.swcrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://json.schemastore.org/swcrc",
3+
"sourceMaps": true,
4+
"jsc": {
5+
"parser": {
6+
"syntax": "typescript",
7+
"decorators": true,
8+
"dynamicImport": true
9+
},
10+
"transform": {
11+
"legacyDecorator": true,
12+
"decoratorMetadata": true
13+
},
14+
"baseUrl": "./"
15+
},
16+
"minify": false
17+
}

packages/create-catalyst/README.md

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,23 @@
1-
# packages/create-catalyst
1+
# create-catalyst
22

3-
> [!WARNING]
4-
> The create-catalyst package is in development and not published to the NPM registry
3+
Create a new Catalyst project, optionally connect the project to a BigCommerce store. Also supports "switching" the store that Catalyst is connected to by running `init`.
54

6-
Scaffolding for Catalyst storefront projects.
7-
8-
## Usage
9-
10-
**NPM:**
11-
12-
```sh
13-
npm create @bigcommerce/catalyst@latest my-catalyst-store
14-
```
15-
16-
**PNPM:**
5+
## NPM
176

187
```sh
19-
pnpm create @bigcommerce/catalyst@latest my-catalyst-store
8+
npm create catalyst-storefront@latest --storeHash your_store_hash --accessToken your_access_token
209
```
2110

22-
**Yarn:**
11+
## PNPM
2312

2413
```sh
25-
yarn create @bigcommerce/catalyst@latest my-catalyst-store
14+
pnpm create catalyst-storefront@latest --storeHash your_store_hash --accessToken your_access_token
2615
```
2716

28-
## Contributing
29-
30-
**Prerequisites:**
31-
32-
- Node `>=18.16`
33-
- [Verdaccio](https://verdaccio.org/) `>=5`
34-
35-
**Developing Locally:**
36-
37-
While developing `create-catalyst` locally, it's essential to test your changes before publishing them to NPM. To achieve this, we utilize Verdaccio, a lightweight private npm proxy registry that you can run in your local environment. By publishing `create-catalyst` to Verdaccio during local development, we can point `[yarn|npm|pnpm] create @bigcommerce/catalyst` at the Verdaccio registry URL and observe how our changes will behave once they are published to NPM.
38-
39-
1. Install Verdaccio: https://verdaccio.org/docs/installation
40-
2. Run Verdaccio: `verdaccio --listen 4873`
41-
3. Add an NPM user with `@bigcommerce` scope to Verdaccio: `npm adduser --scope=@bigcommerce --registry=http://localhost:4873`
42-
43-
> ⚠️ **IMPORTANT:** NPM registry data is immutable, meaning once published, a package cannot change. Be careful to ensure that you do not run commands such as `publish` against the default NPM registry if your work is not ready to be published. Always explicitly pass `--registry=http://localhost:<VERDACCIO_PORT>` with commands that modify the registry (such as `publish`) to ensure you only publish to Verdaccio when working locally.
44-
45-
4. If necessary, run `pnpm build` and `pnpm publish --registry=http://localhost:4873` in each Catalyst-scoped package required by relevant examples listed in `apps/` (e.g., Catalyst `core` examples require `@bigcommerce/components`, `@bigcommerce/eslint-config-catalyst`, `@bigcommerce/catalyst-client`)
46-
5. Run `pnpm build` and `pnpm publish --registry=http://localhost:4873` in the `@bigcommerce/create-catalyst` package
47-
6. Confirm published packages are listed in Verdaccio: http://localhost:4873
48-
49-
In order to point `npm create`, `pnpm create`, and/or `yarn create` to the Verdaccio registry, run one or more of the following commands against the package manager's global configuration:
50-
51-
- **NPM:** `npm config set @bigcommerce:registry http://localhost:4873`
52-
- **PNPM:** `pnpm config set @bigcommerce:registry http://localhost:4873`
53-
- **Yarn:** `yarn config set npmScopes.bigcommerce.npmRegistryServer "http://localhost:4873" -H` and then `yarn config set unsafeHttpWhitelist "localhost" -H`
17+
# To Do
5418

55-
7. Finally, navigate to the directory in which you'd like to create a new Catalyst storefront, and run `[yarn|npm|pnpm] create @bigcommerce/catalyst name-of-your-catalyst-storefront`
19+
- [ ] Channel Site Routes
20+
- [ ] Check Active Storeront Limit
21+
- [ ] Prompt Sample Data API for New Channels
22+
- [ ] Yarn module resolution bug
23+
- [ ] Write root `.vscode/settings.json`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
extensionsToTreatAsEsm: ['.ts'],
3+
transform: {
4+
'^.+\\.(t|j)s?$': '@swc/jest',
5+
},
6+
transformIgnorePatterns: [],
7+
// moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
8+
moduleNameMapper: {
9+
'^(\\.{1,2}/.*)\\.js$': '$1',
10+
},
11+
testEnvironment: 'node',
12+
};

packages/create-catalyst/package.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,44 @@
77
"dist"
88
],
99
"scripts": {
10+
"dev": "tsup --watch",
1011
"typecheck": "tsc --noEmit",
1112
"lint": "eslint . --max-warnings 0",
12-
"test": "jest"
13+
"test": "jest",
14+
"build": "tsup"
1315
},
1416
"engines": {
1517
"node": ">=18.16"
1618
},
19+
"dependencies": {
20+
"@inquirer/prompts": "^3.3.0",
21+
"chalk": "^5.3.0",
22+
"commander": "^11.1.0",
23+
"fs-extra": "^11.2.0",
24+
"giget": "^1.2.1",
25+
"lodash.kebabcase": "^4.1.1",
26+
"lodash.merge": "^4.6.2",
27+
"lodash.set": "^4.3.2",
28+
"lodash.unset": "^4.5.2",
29+
"msw": "^2.1.7",
30+
"nypm": "^0.3.6",
31+
"ora": "^8.0.1",
32+
"zod": "^3.22.4",
33+
"zod-validation-error": "^3.0.0"
34+
},
1735
"devDependencies": {
1836
"@bigcommerce/eslint-config": "^2.7.0",
1937
"@bigcommerce/eslint-config-catalyst": "workspace:^",
38+
"@swc/core": "^1.3.107",
39+
"@swc/jest": "^0.2.34",
40+
"@types/fs-extra": "^11.0.4",
41+
"@types/jest": "^29.5.11",
42+
"@types/lodash.kebabcase": "^4.1.9",
43+
"@types/lodash.merge": "^4.6.9",
44+
"@types/lodash.set": "^4.3.9",
45+
"@types/lodash.unset": "^4.5.9",
2046
"@types/node": "^18.17.12",
47+
"@types/prompts": "^2.4.9",
2148
"eslint": "^8.55.0",
2249
"jest": "^29.7.0",
2350
"prettier": "^3.1.1",

0 commit comments

Comments
 (0)