Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement new cli #82

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

53 changes: 0 additions & 53 deletions .eslintrc.json

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:
push:
branches: ['main', 'next']

permissions:
contents: read

jobs:
autofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- run: pnpm install
- run: pnpm lint:fix
- uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c
with:
commit-message: 'chore: apply automated updates'
45 changes: 19 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
name: CI
name: ci

on:
push:
branches:
- main
- next
pull_request:

# Needed for nx-set-shas within nx-cloud-main.yml, when run on the main branch
permissions:
actions: read
contents: read
branches:
- main
- next

jobs:
main:
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/[email protected]
with:
main-branch-name: main
number-of-agents: 3
init-commands: |
pnpm nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: |
pnpm nx-cloud record -- pnpm nx format:check
parallel-commands-on-agents: |
pnpm nx affected --target=lint --parallel=3
pnpm nx affected --target=test --parallel=3 --ci --code-coverage
pnpm nx affected --target=build --parallel=3

agents:
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/[email protected]
with:
number-of-agents: 3
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- run: pnpm install
- run: pnpm lint
- run: pnpm test:types
- run: pnpm build
- run: pnpm vitest --coverage
28 changes: 0 additions & 28 deletions .verdaccio/config.yml

This file was deleted.

151 changes: 7 additions & 144 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,13 @@ People _love_ thorough bug reports.
## Use a Consistent Coding Style

- 2 spaces for indentation rather than tabs
- You can try running `npm run lint` for style unification
- You can try running `pnpm lint` for style unification

## Development Workflow

In this section, you'll find the basic commands you need to run for building, testing, and maintaining the quality of
the codebase.

This project is structured within an Nx Workspace, providing powerful tools and capabilities to enhance development
practices. For more information, see the [Nx Documentation](https://nx.dev/).

### Repo structure

The project is structured as a monorepo, with each package in the `packages` directory.

To view the list of packages, run:

```shell
pnpm nx show projects
```

The e2e tests are located in the `e2e` directory.

### Nx Cache

Nx uses a cache to speed up development. If you want to bypass the cache, you can use the `--skip-nx-cache` flag:

```shell
pnpm nx build create-solana-dapp --skip-nx-cache
```

### Building the Project

To compile the project and generate the necessary artifacts, use the build command:
Expand All @@ -86,16 +63,10 @@ To compile the project and generate the necessary artifacts, use the build comma
pnpm build
```

To build an individual package, invoke the `nx build` command with the project name:
You can build the project in watch mode by using the following command for faster feedback:

```shell
pnpm nx build create-solana-dapp
```

You can build the project in watch mode by appending the `--watch` flag for faster feedback:

```shell
pnpm nx build create-solana-dapp --watch
pnpm build:watch
```

### Running Tests
Expand All @@ -106,35 +77,10 @@ To ensure your contributions do not break any existing functionality, run the te
pnpm test
```

To run the tests for a specific package, invoke the `nx test` command with the project name:

```shell
pnpm nx test preset-react
```

You can run the tests in watch mode by appending the `--watch` flag for faster feedback:

```shell
pnpm nx test preset-react --watch
```

### Snapshots

To support better testing and tracking of changes to the generated applications, each template preset has snapshots
generated (which are committed). As part of the each preset's `test`, its respective snapshot is checked to verify
generated output is as expected.

When making adjustments to a generator that affected the outputted scaffold, the respective preset's snapshot will need
to be updated.

To update all snapshots, run the `test` for each preset via NX with the update flag (i.e. `-u`):
You can run the tests in watch mode by running the following command for faster feedback:

```shell
# full command
pnpm nx run-many --target test --skip-nx-cache -u

# or the shorthand script
pnpm test -u
pnpm dev
```

### Linting Your Code
Expand All @@ -145,12 +91,6 @@ It's important to maintain the coding standards of the project. Lint your code b
pnpm lint
```

To lint a specific package, invoke the `nx lint` command with the project name:

```shell
pnpm nx lint preset-react
```

### Working on the CLI

If you want to quickly test your changes to the CLI, you can do the following:
Expand All @@ -160,94 +100,17 @@ If you want to quickly test your changes to the CLI, you can do the following:
Run the build in watch mode in one terminal:

```shell
pnpm nx build create-solana-dapp --watch
pnpm build:watch
```

In another terminal, move to the directory where you want to test the `create-solana-dapp` CLI and run by invoking the
`node` command with the path to the compiled CLI:

```shell
cd /tmp
node ~/path/to/create-solana-dapp/dist/packages/create-solana-dapp/bin/index.js --help
```

#### solana-dev

The same goes for the `solana-dev` CLI:

```shell
# In one terminal
pnpm nx build solana-dev --watch
# In another terminal
cd /tmp
node ~/path/to/create-solana-dapp/dist/packages/solana-dev/bin/index.js --help
```

### Publishing to a local registry

If you want to test your changes to the CLI in a local registry, you can do the following:

Start the local registry:

```shell
pnpm local-registry
```

In another terminal, run the following command to publish the packages to the local registry:

```shell
pnpm local-publish <your-version>
```

Note: This will publish all the packages to the local registry with the `local` tag. Therefore, to utilize any of these
packages from your local registry, you must specify using this same `local` tag on the packages (e.g.
`create-solana-dapp@local`).

Once that's done, with the local registry still running, you can run the `create-solana-dapp` CLI by invoking the
following command:

```shell
npx create-solana-dapp@local
```

For example, this one-liner will create a new app with the latest version of the `create-solana-dapp` CLI using the
React preset and yarn as the package manager:

```shell
npx --yes create-solana-dapp@local app-"$(date +%s)" --preset react --package-manager yarn
```

To check all the options, run:

```shell
npx create-solana-dapp@local --help
node ~/path/to/create-solana-dapp/dist/bin/index.cjs --help
```

The local registry will be running at http://localhost:4873 and in order to use it, changes to the `~/.npmrc` file are
required. The local-registry script will do this for you, but it might fail to clean up after itself. If you run into
any issues, try removing the following lines from your `~/.npmrc` file:

```shell
registry=http://localhost:4873/
//localhost:4873/:_authToken=secretVerdaccioToken
```

and replace them with:

```shell
registry=https://registry.npmjs.org/
```

### E2E Testing

To run the e2e tests, use the following command:

```shell
pnpm nx e2e preset-react-e2e
```

This will spin up a local registry, publish a package with the e2e tag, and run the e2e tests.

### Committing Your Changes

We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification for commit:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Solana Foundation
Copyright (c) 2022-2024 Solana Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading