-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): CATALYST-246 create-catalyst login, create env, scaffold p…
…roject
- Loading branch information
1 parent
8831cbc
commit b6a6100
Showing
24 changed files
with
1,834 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Create Catalyst CLI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
types: [opened, synchronize] | ||
merge_group: | ||
types: [checks_requested] | ||
|
||
jobs: | ||
integration-tests: | ||
name: Integration Tests | ||
|
||
runs-on: ubuntu-latest | ||
|
||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | ||
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }} | ||
BIGCOMMERCE_STORE_HASH: ${{ secrets.BIGCOMMERCE_STORE_HASH }} | ||
BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN: ${{ secrets.BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@main | ||
with: | ||
fetch-depth: 2 | ||
|
||
- uses: pnpm/action-setup@v2 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@main | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Build CLI | ||
run: pnpm build | ||
working-directory: packages/create-catalyst | ||
|
||
- name: Run CLI | ||
run: | | ||
node dist/index.js \ | ||
--ghRef ${{ github.ref}} \ | ||
--projectDir ${{ runner.temp }} \ | ||
--projectName catalyst-integration-test \ | ||
--channelId 1 \ | ||
--accessToken some_access_token \ | ||
--storeHash ${{ secrets.BIGCOMMERCE_STORE_HASH }} \ | ||
--customerImpersonationToken ${{ secrets.BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN }} | ||
working-directory: packages/create-catalyst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Create Catalyst CLI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
types: [opened, synchronize] | ||
merge_group: | ||
types: [checks_requested] | ||
|
||
jobs: | ||
unit-tests: | ||
name: Unit Tests | ||
|
||
runs-on: ubuntu-latest | ||
|
||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | ||
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }} | ||
BIGCOMMERCE_STORE_HASH: ${{ secrets.BIGCOMMERCE_STORE_HASH }} | ||
BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN: ${{ secrets.BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@main | ||
with: | ||
fetch-depth: 2 | ||
|
||
- uses: pnpm/action-setup@v2 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@main | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Run Tests | ||
run: pnpm test | ||
working-directory: packages/create-catalyst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/swcrc", | ||
"sourceMaps": true, | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"decorators": true, | ||
"dynamicImport": true | ||
}, | ||
"transform": { | ||
"legacyDecorator": true, | ||
"decoratorMetadata": true | ||
}, | ||
"baseUrl": "./" | ||
}, | ||
"minify": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,22 @@ | ||
# packages/create-catalyst | ||
# create-catalyst | ||
|
||
> [!WARNING] | ||
> The create-catalyst package is in development and not published to the NPM registry | ||
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`. | ||
|
||
Scaffolding for Catalyst storefront projects. | ||
|
||
## Usage | ||
|
||
**NPM:** | ||
|
||
```sh | ||
npm create @bigcommerce/catalyst@latest my-catalyst-store | ||
``` | ||
|
||
**PNPM:** | ||
## NPM | ||
|
||
```sh | ||
pnpm create @bigcommerce/catalyst@latest my-catalyst-store | ||
npm create catalyst-storefront@latest --storeHash your_store_hash --accessToken your_access_token | ||
``` | ||
|
||
**Yarn:** | ||
## PNPM | ||
|
||
```sh | ||
yarn create @bigcommerce/catalyst@latest my-catalyst-store | ||
pnpm create catalyst-storefront@latest --storeHash your_store_hash --accessToken your_access_token | ||
``` | ||
|
||
## Contributing | ||
|
||
**Prerequisites:** | ||
|
||
- Node `>=18.16` | ||
- [Verdaccio](https://verdaccio.org/) `>=5` | ||
|
||
**Developing Locally:** | ||
|
||
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. | ||
|
||
1. Install Verdaccio: https://verdaccio.org/docs/installation | ||
2. Run Verdaccio: `verdaccio --listen 4873` | ||
3. Add an NPM user with `@bigcommerce` scope to Verdaccio: `npm adduser --scope=@bigcommerce --registry=http://localhost:4873` | ||
|
||
> ⚠️ **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. | ||
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`) | ||
5. Run `pnpm build` and `pnpm publish --registry=http://localhost:4873` in the `@bigcommerce/create-catalyst` package | ||
6. Confirm published packages are listed in Verdaccio: http://localhost:4873 | ||
|
||
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: | ||
|
||
- **NPM:** `npm config set @bigcommerce:registry http://localhost:4873` | ||
- **PNPM:** `pnpm config set @bigcommerce:registry http://localhost:4873` | ||
- **Yarn:** `yarn config set npmScopes.bigcommerce.npmRegistryServer "http://localhost:4873" -H` and then `yarn config set unsafeHttpWhitelist "localhost" -H` | ||
# To Do | ||
|
||
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` | ||
- [ ] Channel Site Routes | ||
- [ ] Check Active Storeront Limit | ||
- [ ] Prompt Sample Data API for New Channels | ||
- [ ] Yarn module resolution bug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
flowchart TD | ||
A[npm/pnpm/yarn create @bigcommerce/catalyst@latest] --> B[Login to BigCommerce Store] | ||
A --> C[Use Sample Data] | ||
C --> D[@todo] | ||
B --> E[Check Active Storefront Limit for Store] | ||
E -->|User Allowed to Create Channel| F[Create New Channel] | ||
E -->|User Unable to Create Channel| G[Use Existing Channel] | ||
F -->|YES| H[Enter a Name for Your New Channel] | ||
F -->|NO| G | ||
G --> M | ||
H --> I[Channel Name Already Taken] | ||
I --> H | ||
H --> J[Channel Created Successfully] | ||
J --> K[Do you want create Sample Data for your New Channel?] | ||
K -->|YES| L[Hit Cloudflare Worker to Seed New Channel] | ||
K -->|NO| M[Create Channel Site URL] | ||
L --> M | ||
M --> N[Create Channel Site Checkout URL] | ||
N --> O[Create Channel Routes] | ||
O --> P[Create Customer Impersonation Token] | ||
P --> Q[Generate JWT Signing Secret for NextAuth] | ||
Q --> R[Create Required Environment Variables to run Catalyst Next.js App] | ||
R --> S[Clone Catalyst Template from GitHub] | ||
S --> T[Copy Catalyst Components from GitHub] | ||
T --> U[Reconcile Configuration Files - Tailwind, TsConfig, Package.json] | ||
U --> V[Write Configuration Files and Environment Variable File] | ||
V --> W[Install Dependencies] | ||
W --> X[Run GraphQL Codegen] | ||
X --> Y[Lint to Validate Types] | ||
Y --> Z[Successfully Created Catalyst Project] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
extensionsToTreatAsEsm: ['.ts'], | ||
transform: { | ||
'^.+\\.(t|j)s?$': '@swc/jest', | ||
}, | ||
transformIgnorePatterns: [], | ||
// moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
moduleNameMapper: { | ||
'^(\\.{1,2}/.*)\\.js$': '$1', | ||
}, | ||
testEnvironment: 'node', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.