Skip to content

Commit

Permalink
Merge pull request #313 from plopjs/monorepo
Browse files Browse the repository at this point in the history
Monorepo
  • Loading branch information
crutchcorn committed Apr 25, 2022
2 parents 13fe141 + 06da26c commit ae2a6bf
Show file tree
Hide file tree
Showing 226 changed files with 25,254 additions and 13,299 deletions.
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "plopjs/plop" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
31 changes: 29 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
const ts = {
files: ["**/*.ts"],
extends: [
"plugin:prettier/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
project: "./tsconfig.json",
allowImportExportEverywhere: true,
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unused-vars": "off",
"prefer-const": "off"
},
};

module.exports = {
env: {
commonjs: true,
es2021: true,
es6: true,
node: true,
jest: true,
},
parserOptions: {
sourceType: "module",
"allowImportExportEverywhere": true
ecmaVersion: 2021,
allowImportExportEverywhere: true,
},
extends: ["plugin:prettier/recommended"],
rules: {
// https://github.com/plopjs/plop/issues/288
"linebreak-style": ["error", "unix"],
},
overrides: [ts],
};
28 changes: 10 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,21 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
node: [ 12, 14, 16 ]
node: [ 14, 16 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: ${{ matrix.node }}
cache: yarn

# From: https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
run: npm ci
run: yarn install --frozen-lockfile

- name: Bootstrap Dependencies
run: yarn bootstrap

- name: Test
run: npm test
run: yarn test
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
node_modules/
*.sublime-*
example/folder/
example/change-me.txt
.idea
.vscode
.DS_STORE
.nyc_output
coverage
instrumented/
.eslintcache
yarn-error.log
.nyc_output
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
For each change made (anything not marked as a "chore"), run the following command:
```
yarn changeset add
```

This will allow you to do the following:

1) Select impacted packages
2) Add a related message
3) Notify what type of package bump is required (major, minor, patch)

-------

# Releasing

When a maintainer is ready to publish, run the following command to generate a changelog:

```
yarn changeset version
```

You should then verify, using your Git CLI or Git GUI, that the CHANGELOG is correct, everything is up-to-date, and that you're ready to release!

> **Do not create a commit manually after "yarn changeset version"**.
Then, once you've ran `version`, run the following command to publish to NPM:

```
yarn changeset publish
```
8 changes: 8 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"packages": [
"packages/*"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.0.0"
}
119 changes: 51 additions & 68 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,51 @@
{
"name": "plop",
"version": "3.0.5",
"description": "Micro-generator framework that makes it easy for an entire team to create files with a level of uniformity",
"main": "./src/plop.js",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/plopjs/plop.git"
},
"keywords": [
"generator",
"scaffolding",
"yeoman",
"make",
"build",
"generate",
"gen",
"plop"
],
"author": "Andrew Worcester <andrew@amwmedia.com> (http://amwmedia.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/plopjs/plop/issues"
},
"scripts": {
"test": "npm run test:instrument && npm run vitest && nyc report",
"test:instrument": "nyc instrument ./bin ./instrumented/bin && nyc instrument ./src ./instrumented/src && cp package.json ./instrumented",
"vitest": "vitest run",
"format": "eslint --fix ./",
"prepare": "husky install"
},
"devDependencies": {
"cli-testing-library": "^1.0.1",
"eslint": "^8.3.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"inquirer-directory": "^2.2.0",
"lint-staged": "^12.1.2",
"nyc": "^15.1.0",
"plop-pack-fancy-comments": "^0.2.0",
"prettier": "^2.5.0",
"queue-microtask": "^1.2.3",
"vitest": "^0.5.5"
},
"homepage": "https://plopjs.com",
"dependencies": {
"@types/liftoff": "^4.0.0",
"chalk": "^5.0.0",
"interpret": "^2.2.0",
"liftoff": "^4.0.0",
"minimist": "^1.2.5",
"node-plop": "^0.30.0",
"ora": "^6.0.1",
"v8flags": "^4.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"preferGlobal": true,
"bin": {
"plop": "./bin/plop.js"
},
"lint-staged": {
"*.js": "eslint --cache --fix"
}
}
{
"name": "plop-monorepo",
"version": "0.0.0",
"private": true,
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**/plop-pack-fancy-comments"
]
},
"type": "module",
"scripts": {
"bootstrap": "lerna exec yarn install",
"build": "lerna run build",
"test": "lerna run --parallel test",
"format": "eslint -c .eslintrc.cjs --fix ./",
"prepare": "husky install",
"plop": "node ./packages/plop/bin/plop.js"
},
"bugs": {
"url": "https://github.com/plopjs/plop/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/plopjs/plop.git"
},
"homepage": "https://plopjs.com",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.4",
"@changesets/cli": "^2.22.0",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"eslint": "^8.9.0",
"eslint-config-prettier": "^8.4.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"lerna": "^4.0.0",
"lint-staged": "^12.1.2",
"prettier": "^2.5.1",
"typescript": "^4.5.2"
},
"lint-staged": {
"*.js": "eslint --cache --fix"
}
}
24 changes: 24 additions & 0 deletions packages/node-plop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Compiled src
lib

# Test mocks
tests/*-mock/src

# IDE files
.idea
5 changes: 5 additions & 0 deletions packages/node-plop/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tests
.*rc
build-scripts
plopfile.js
plop-templates
21 changes: 21 additions & 0 deletions packages/node-plop/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Andrew Worcester

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions packages/node-plop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Node-Plop
======

[![npm](https://img.shields.io/npm/v/node-plop.svg)](https://www.npmjs.com/package/node-plop)
[![GitHub actions](https://img.shields.io/github/workflow/status/plopjs/node-plop/test)](https://github.com/plopjs/node-plop/actions/workflows/test.yml)

This is an early publication of the plop core logic being removed from the CLI tool. Main purpose for this is to make it easier for others to automate code generation through processes and tools OTHER than the command line. This also makes it easier to test the code functionality of PLOP without needing to test via the CLI interface.

This is the backend code that drives the plop CLI tool using node-plop.

``` javascript
import nodePlop from 'node-plop';
// load an instance of plop from a plopfile
const plop = await nodePlop(`./path/to/plopfile.js`);
// get a generator by name
const basicAdd = plop.getGenerator('basic-add');

// run all the generator actions using the data specified
basicAdd.runActions({name: 'this is a test'}).then(function (results) {
// do something after the actions have run
});
```
3 changes: 3 additions & 0 deletions packages/node-plop/build-scripts/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as del from "del";

del.sync("./lib");
Loading

0 comments on commit ae2a6bf

Please sign in to comment.