Skip to content

Commit

Permalink
feat(nx-plugin): Improve migratability of loosely-structured files (#117
Browse files Browse the repository at this point in the history
)

* Improve migratability of loosely-structured files

* prolog --> prologue

* Tweak section naming
  • Loading branch information
luxaritas authored Aug 16, 2022
1 parent f5b16cc commit 85e9bbb
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 40 deletions.
52 changes: 35 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
/tmp
/out-tsc
# Compiled output (Managed by @eternagame/nx-plugin)
dist/

# dependencies
# Temps and caches (Managed by @eternagame/nx-plugin)
tmp
.temp
.cache

# Dependencies (Managed by @eternagame/nx-plugin)
node_modules

# IDEs and editors
# IDEs and editors (Managed by @eternagame/nx-plugin)
/.idea
.project
.classpath
Expand All @@ -17,26 +20,41 @@ node_modules
.settings/
*.sublime-workspace

# IDE - VSCode
# IDE - VSCode (Managed by @eternagame/nx-plugin)
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
# dotenv environment variable files (Managed by @eternagame/nx-plugin)
.env.*.local
.env.local

# Diagnostic reports (https://nodejs.org/api/report.html) (Managed by @eternagame/nx-plugin)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Test coverage (Managed by @eternagame/nx-plugin)
coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
# Logs (Managed by @eternagame/nx-plugin)
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Runtime data (Managed by @eternagame/nx-plugin)
pids
*.pid
*.seed
*.pid.lock

# System Files (Managed by @eternagame/nx-plugin)
.DS_Store
Thumbs.db

# Nx migrations
# Nx migrations (Managed by @eternagame/nx-plugin)
migrations.json
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"nrwl.angular-console",
"dbaeumer.vscode-eslint",
"firsttris.vscode-jest-runner"
"firsttris.vscode-jest-runner",
"EditorConfig.EditorConfig"
]
}
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

Helper packages for JS projects

<!-- Managed by @eternagame/nx-plugin - prologue -->
Interested in development? Join the discussion on the Eterna Discord!

[![Eterna Discord](https://discord.com/api/guilds/702618517589065758/widget.png?style=banner2)](https://discord.gg/KYeTwux)
<!-- End managed by @eternagame/nx-plugin - prologue -->

## Components

Expand All @@ -26,41 +28,54 @@ configuration and package generators.

- [`@eternagame/nx-spawn`](./packages/nx-spawn) - Run an npm command with Nx dependencies without waiting for them to finish

<!-- Managed by @eternagame/nx-plugin - setup -->
## Setup

- Install [NodeJS](https://nodejs.org/en/download/) (we recommend using the latest LTS version)
- Run `npm install` in the root of this repository
<!-- End managed by @eternagame/nx-plugin - setup -->

<!-- Managed by @eternagame/nx-plugin - commands -->
## Common Commands

This project is structured as a monorepo, using [NPM Workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces)
and [Nx](https://nx.dev/) to manage its components. Here are some common actions you might want to take:
<!-- End managed by @eternagame/nx-plugin - commands -->

<!-- Managed by @eternagame/nx-plugin - commands/run -->
### Running Apps

Run `npx nx dev <package-name>` to run an application package, automatically reloading when changes occur.

Run `npx nx start <package-name>` to run after building the package (with dependencies) without reloading.
<!-- End managed by @eternagame/nx-plugin - commands/run -->

<!-- Managed by @eternagame/nx-plugin - commands/build -->
### Build

Run `npx nx build <package-name>` to build a package. This will also build any dependencies of the package.

Run `npx nx build:watch <package-name>` to build a package and rebuild when files are changed.
This will also build any dependencies of the package.
<!-- End managed by @eternagame/nx-plugin - commands/build -->

<!-- Managed by @eternagame/nx-plugin - commands/lint -->
### Linting and Formatting

Run `npx nx lint <package-name>` to run linting for a package via [ESLint](https://eslint.org/).

Run `npx nx lint <package-name> --fix` to run linting with automatic fixes
<!-- End managed by @eternagame/nx-plugin - commands/lint -->

<!-- Managed by @eternagame/nx-plugin - commands/test -->
### Unit Tests

Run `npx nx test <package-name>` to execute the unit tests for a package via [Jest](https://jestjs.io/).

Run `npx nx affected:test` to execute the unit tests for all packages affected by a code change.
<!-- End managed by @eternagame/nx-plugin - commands/test -->

<!-- Managed by @eternagame/nx-plugin - commands/generate -->
### Code Generation

You can use the Eterna Nx plugin to automatically create and update files, including adding new packages.
Expand All @@ -70,6 +85,7 @@ run `npx nx generate <generator>` (eg, `npx nx generate ts-iso`). Running `npx n
will show available options for that generator. In particular, if generating a new package, you may want to pass
the `--directory` flag to put the package in a specific subdirectory of the packages directory if you don't
want it placed in the root.
<!-- End managed by @eternagame/nx-plugin - commands/generate -->

### Updating Dependencies

Expand All @@ -92,7 +108,7 @@ changes that we may want to incorporate:
If you're on a unix-like system and want to remove all nested node_modules folders,
you can run `find . -type d -name node_modules -prune | xargs rm -r`

### Testing packages outside this project
## Testing packages outside this project

If you want to test changes to packages outside of this project, you will need a way to install your
local version in whatever other project you're using. There are generally two ways to do this:
Expand Down
24 changes: 12 additions & 12 deletions packages/nx-plugin/src/generators/preset/files/.gitignore__tmpl__
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
# Compiled output (Managed by @eternagame/nx-plugin)
dist/

# Temps and caches
# Temps and caches (Managed by @eternagame/nx-plugin)
tmp
.temp
.cache

# Dependencies
# Dependencies (Managed by @eternagame/nx-plugin)
node_modules

# IDEs and editors
# IDEs and editors (Managed by @eternagame/nx-plugin)
/.idea
.project
.classpath
Expand All @@ -20,24 +20,24 @@ node_modules
.settings/
*.sublime-workspace

# IDE - VSCode
# IDE - VSCode (Managed by @eternagame/nx-plugin)
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
# dotenv environment variable files (Managed by @eternagame/nx-plugin)
.env.*.local
.env.local

# Diagnostic reports (https://nodejs.org/api/report.html)
# Diagnostic reports (https://nodejs.org/api/report.html) (Managed by @eternagame/nx-plugin)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Test coverage
# Test coverage (Managed by @eternagame/nx-plugin)
coverage

# Logs
# Logs (Managed by @eternagame/nx-plugin)
logs
*.log
npm-debug.log*
Expand All @@ -46,15 +46,15 @@ yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Runtime data
# Runtime data (Managed by @eternagame/nx-plugin)
pids
*.pid
*.seed
*.pid.lock

# System Files
# System Files (Managed by @eternagame/nx-plugin)
.DS_Store
Thumbs.db

# Nx migrations
# Nx migrations (Managed by @eternagame/nx-plugin)
migrations.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"nrwl.angular-console",
"dbaeumer.vscode-eslint",
"firsttris.vscode-jest-runner"
"firsttris.vscode-jest-runner",
"EditorConfig.EditorConfig"
]
}
20 changes: 19 additions & 1 deletion packages/nx-plugin/src/generators/preset/files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,58 @@

<%= description %>

<%= readmeProlog %>
<!-- Managed by @eternagame/nx-plugin - prologue -->
<%= readmePrologue %>
<!-- End managed by @eternagame/nx-plugin - prologue -->

<!-- Managed by @eternagame/nx-plugin - setup -->
## Setup

- Install [NodeJS](https://nodejs.org/en/download/) (we recommend using the latest LTS version)
- Run `npm install` in the root of this repository
<!-- End managed by @eternagame/nx-plugin - setup -->

<!-- Managed by @eternagame/nx-plugin - commands -->
## Common Commands

This project is structured as a monorepo, using [NPM Workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces)
and [Nx](https://nx.dev/) to manage its components. Here are some common actions you might want to take:
<!-- End managed by @eternagame/nx-plugin - commands -->

<!-- Managed by @eternagame/nx-plugin - commands/run -->
### Running Apps

Run `npx nx dev <package-name>` to run an application package, automatically reloading when changes occur.

Run `npx nx start <package-name>` to run after building the package (with dependencies) without reloading.
<!-- End managed by @eternagame/nx-plugin - commands/run -->

<!-- Managed by @eternagame/nx-plugin - commands/build -->
### Build

Run `npx nx build <package-name>` to build a package. This will also build any dependencies of the package.

Run `npx nx build:watch <package-name>` to build a package and rebuild when files are changed.
This will also build any dependencies of the package.
<!-- End managed by @eternagame/nx-plugin - commands/build -->

<!-- Managed by @eternagame/nx-plugin - commands/lint -->
### Linting and Formatting

Run `npx nx lint <package-name>` to run linting for a package via [ESLint](https://eslint.org/).

Run `npx nx lint <package-name> --fix` to run linting with automatic fixes
<!-- End managed by @eternagame/nx-plugin - commands/lint -->

<!-- Managed by @eternagame/nx-plugin - commands/test -->
### Unit Tests

Run `npx nx test <package-name>` to execute the unit tests for a package via [Jest](https://jestjs.io/).

Run `npx nx affected:test` to execute the unit tests for all packages affected by a code change.
<!-- End managed by @eternagame/nx-plugin - commands/test -->

<!-- Managed by @eternagame/nx-plugin - commands/generate -->
### Code Generation

You can use the Eterna Nx plugin to automatically create and update files, including adding new packages.
Expand All @@ -48,7 +63,9 @@ run `npx nx generate <generator>` (eg, `npx nx generate ts-iso`). Running `npx n
will show available options for that generator. In particular, if generating a new package, you may want to pass
the `--directory` flag to put the package in a specific subdirectory of the packages directory if you don't
want it placed in the root.
<!-- End managed by @eternagame/nx-plugin - commands/generate -->

<!-- Managed by @eternagame/nx-plugin - commands/update -->
### Updating Dependencies

When upgrading `@eternagame/nx-plugin`, there may be changes to the repository that should be made when updating.
Expand All @@ -64,3 +81,4 @@ For updating other dependencies, you may want to use `npx npm-check-updates --de

If you're on a unix-like system and want to remove all nested node_modules folders,
you can run `find . -type d -name node_modules -prune | xargs rm -r`
<!-- End managed by @eternagame/nx-plugin - commands/update -->
6 changes: 3 additions & 3 deletions packages/nx-plugin/src/generators/preset/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { installDevDependencies } from '../../utils/dependencies';

const ETERNA_NPM_SCOPE = 'eternagame';
const ETERNA_COPYRIGHT_HOLDER = 'Eterna Commons';
const ETERNA_README_PROLOG = `Interested in development? Join the discussion on the Eterna Discord!
const ETERNA_README_PROLOGUE = `Interested in development? Join the discussion on the Eterna Discord!
[![Eterna Discord](https://discord.com/api/guilds/702618517589065758/widget.png?style=banner2)](https://discord.gg/KYeTwux)`;

Expand All @@ -20,7 +20,7 @@ interface Schema {
npmScope: string;
license: 'MIT' | 'BSD3' | 'EternaNoncommercial' | 'Custom' | 'None';
copyrightHolder: string;
readmeProlog: string;
readmePrologue: string;
eternaDefaults: boolean;
}

Expand All @@ -29,7 +29,7 @@ function normalizeOptions(options: Schema): Schema {

if (opts.eternaDefaults) {
opts.copyrightHolder ||= ETERNA_COPYRIGHT_HOLDER;
opts.readmeProlog ||= ETERNA_README_PROLOG;
opts.readmePrologue ||= ETERNA_README_PROLOGUE;
opts.npmScope ||= ETERNA_NPM_SCOPE;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/nx-plugin/src/generators/preset/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"x-prompt": "If you've specified a license, who is the copyright holder?",
"default": ""
},
"readmeProlog": {
"readmePrologue": {
"type": "string",
"description": "Additional information to add as part of the high-level description in the README",
"default": ""
Expand Down

0 comments on commit 85e9bbb

Please sign in to comment.