Skip to content

Commit

Permalink
docs(docs-content): 📝 update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
linbudu599 committed Oct 4, 2021
1 parent 2368ec7 commit a77b935
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 17 deletions.
19 changes: 18 additions & 1 deletion docs/nx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,21 @@ permalink: /:slug

# Nx Plugin Overview

TODO...
## Avaliable Nx Plugins

- [nx-plugin-esbuild](esbuild.md)
- [nx-plugin-snowpack](snowpack.md)
- [nx-plugin-vite](vite.md)
- [nx-plugin-prisma](prisma.md)

## Nx Plugin Helper

- [nx-plugin-devkit](devkit.md)
- [nx-plugin-workspace](workspace.md)

## Incoming Nx Plugins

- nx-plugin-astro
- nx-plugin-midway
- nx-plugin-ice
- nx-plugin-swc
32 changes: 31 additions & 1 deletion docs/nx/devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,34 @@ permalink: /:slug

# Devkit

Devkit 西内!
Useful utilities in nx plugin development.

## Executors

- `ensureProjectConfig`: Ensure project has `projectSourceRoot` & `projectRoot` config fields.
- `envInfo`: Report system environment informations, used by `info` executor.
- `readTargetOptions`: Read target options by given target.

You can found more executors utils in `@nrwl/devkit`.

## Generators

- `installPackagesTask`: Execute install task in `app` generator.
- `minimalNormalizeOptions` `minimalAddFiles` `minimalProjectConfiguration`: These methods help you to create simple application generator which requires only serveral schema options like`name` `tags` `directory`.
- `createNodeAppBuildConfig` `createNodeAppServeConfig`: Compose build /serve configuration for node project in `workspace.project`
- `setupProxy` `updateNodeAppDeps` `initializeNodeApp` `createNodeAppProject` `createNodeAppFiles`: Utilities for creating node application.
- `createNodeInitTask` `createNodeJestTask` `createNodeLintTask`: Utilities for initialzing node application.
- `normalizeNodeAppSchema`: Normalize node application schema, including node specified options.
- `createPackageJSON` `updatePackageJson`: Operating your `package.json` with ease.

## Workspace

- `checkProjectExist`: Check does project exist in current workspace.
- `getAvailableAppsLibs`: Get all avaliable apps & libs.
- `setDefaultProject`: Set workspace default project if no specified default project exists.
- `updateGitIgnore` `updatePrettierIgnore`: Update ignore file.

## Utils

- `normalizeAssets` `copyAssetFiles`: Normalize assets configuration and do copy.
- `normalizeFileReplacements` `fileReplacements2Alias`: Normalize file replacements, transform them into alias form.
8 changes: 4 additions & 4 deletions docs/nx/esbuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ create a node application project with esbuild-based workspace configuration, fo
}
```

Most of `ESBuild.BuildOptions` are supported in schema options, but it's recommended to use extend config file for programmatic configuration.
- By default, we use `outputPath` inside project dir instead of hoist to workspace root. You can change this behavior by modifying the `outputPath` field.

In initial generated application, there'll be a `nx-esbuild.ts` file exist in project root:
Most of `ESBuild.BuildOptions` are supported in schema options, but it's recommended to use extend config file for programmatic configuration, so in initial generated application, there'll be a `nx-esbuild.ts` config file exist in project root:

```typescript
import { NXESBuildConfigExport } from 'nx-plugin-esbuild';
Expand Down Expand Up @@ -88,7 +88,7 @@ You can configurate `buildOptions` and `watchOptions` here, which makes configur
**NOTE: To load `.ts` config file by `require`(use [@adonisjs/require-ts](https://www.npmjs.com/package/@adonisjs/require-ts) under the hood), you will need `compilerOptions.module` to be set as `CommonJS`.
Failure to load does not cause the program to exit but to skip loading config file.**

**NOTE: Make sure to have `extendConfig: 'config-path.ext'`(relative to project root) in workspace config(`project.targets.esbuild-build.options`).**
**NOTE: Make sure to have `extendConfig: 'config-path.ext'`(relative to project root) in workspace config(`project.targets.esbuild-build.options`) when you wants to use extend config file.**

More supported schema options can be found in [ESBuild.Generator.NodeInit](/packages/nx-plugin-esbuild/src/generators/node-init/schema.json).

Expand All @@ -98,7 +98,7 @@ More supported schema options can be found in [ESBuild.Generator.NodeInit](/pack
nx g nx-plugin-esbuild:node-setup exist-node-app
```

Similar to `init` generator, but `setup` generator should be applied in exist node application, and create related target configurations in `workspace.json`.
Similar to `node-init` generator, but `node-setup` generator should be applied in exist node application, and create related target configurations in `workspace.json`.

You can find more supported schema options in [ESBuild.Generator.Setup](/packages/nx-plugin-esbuild/src/generators/setup/schema.json).

Expand Down
2 changes: 1 addition & 1 deletion docs/nx/prisma.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Nx plugin integration with [Prisma](https://www.prisma.io/)
yarn add @prisma/client
yarn add nx-plugin-prisma prisma -D
# some required peer deps in nx workspace
yarn add @nrwl/node @nrwl/workspace @angular-devkit/schematics -D
yarn add @nrwl/node @nrwl/workspace @nrwl/tao @angular-devkit/schematics -D
```

## Generators
Expand Down
8 changes: 5 additions & 3 deletions docs/nx/snowpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ yarn add @nrwl/node @nrwl/workspace @nrwl/tao @angular-devkit/schematics -D
### app

```bash
nx g nx-plugin-snowpack:app snowpack-app
nx g nx-plugin-snowpack:app snowpack-app --framework=react
```

Create official `Snowpack` + `React` template and add plugin related workspace targets.
Create official `Snowpack` template and add plugin related workspace targets.

Supported framework: `React`(default), `Vue`, `Svelte`

### setup

Expand All @@ -35,7 +37,7 @@ Add plugin related workspace targets to exist application.

## Executors

**NOTE: In Nx-Snowpack project, it's recommended to configurate your snowpack project by `PROJECT/snowpack.config.cjs`(which also has a higher priority) instead of schema options. Schema options will be ignored totally when config path specified.**
**NOTE: In Nx-Snowpack project, it's recommended to configurate your snowpack project by `PROJECT/snowpack.config.mjs`(which also has a higher priority) instead of schema options. Schema options will be ignored totally when config path specified.**

### serve

Expand Down
8 changes: 5 additions & 3 deletions docs/nx/vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ yarn add @nrwl/node @nrwl/workspace @nrwl/tao @angular-devkit/schematics -D
### app

```bash
nx g nx-plugin-vite:app your-vite-app
nx g nx-plugin-vite:app your-vite-app --framework=react
```

Create a official `Vite` + `React` template and add plugin related workspace targets in `workspace.json`.
Create a official `Vite` template and add plugin related workspace targets in `workspace.json`.

Supported framework: `React`(default), `Vue`

### setup

```bash
nx g nx-plugin-vite:setup exist-vite-app
nx g nx-plugin-vite:setup exist-app
```

Add plugin related workspace targets to **exist application**.
Expand Down
28 changes: 28 additions & 0 deletions docs/nx/workspace.md
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
# Workspace

Some extra enhancements on offical `@nrwl/workspace`:

## Executors

- `nx-plugin-workspace:exec`

Similar to `@nrwl/workspace:run-commands`, with enhancements below:

- Use [`execa`](https://www.npmjs.com/package/execa) under the hood, support `preferLocal` `shell` and more options.
- Support `ignoreFalsy`: will not append falsy value into command to execute, like `--watch=false`, which is useful in `Prisma` cli.
- Support `useCamelCase`: control how args are transformed, kebab-case or camel-case?

- `nx-plugin-workspace:node-build`: `@nrwl/node:build`
- `nx-plugin-workspace:node-serve`: `@nrwl/node:serve`
- `nx-plugin-workspace:node-package`: `@nrwl/node:package`
- `nx-plugin-workspace:tsc`: `@nrwl/workspace:tsc`

## Generators

### react-scripts

```bash
nx g nx-plugin-workspace:react-scripts react-app
```

Create offical `Create-React-App` template application, and `React-Scripts` related targets
.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Tree } from '@nrwl/tao/src/shared/tree';
import { execSync } from 'child_process';
import { join } from 'path';
import {
detectPackageManager,
Expand Down
8 changes: 5 additions & 3 deletions scripts/release/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ export default function useReleaseProject(cli: CAC) {
}));

dryRunSuccessLogger(
`Package ${projectToRelease} built successfully.`,
`Package ${projectToRelease} built successfully.\n`,
dryRun
);

consola.info('Updating necessary fields of `dist/package.json`...');
consola.info('Updating necessary fields of `dist/package.json`...\n');

const builtPkgInfo = jsonfile.readFileSync(builtProjectPkgPath);

Expand Down Expand Up @@ -288,7 +288,7 @@ export default function useReleaseProject(cli: CAC) {
}
);

console.log('');
console.log('\n');

await execa(
'git',
Expand All @@ -303,6 +303,8 @@ export default function useReleaseProject(cli: CAC) {
consola.warn('Remember you have skipped git process.');
}

console.log('\n');

dryRunInfoLogger('Pubishing package...', dryRun);

const { stdout: logAs } = await execa('npm', ['whoami'], {
Expand Down

0 comments on commit a77b935

Please sign in to comment.