├── .gitignore ├── .github ├── workflows │ ├── CODEOWNERS │ └── ci.yaml └── dependabot.yml ├── packages └── create-pkg │ ├── test │ ├── tmp │ │ ├── .npmrc │ │ ├── index.js │ │ ├── test │ │ │ └── index.js │ │ ├── .github │ │ │ ├── CODE_OF_CONDUCT.md │ │ │ ├── SECURITY.md │ │ │ ├── CONTRIBUTING.md │ │ │ └── workflows │ │ │ │ └── test.yml │ │ ├── package.json │ │ ├── README.md │ │ ├── LICENSE │ │ └── .gitignore │ └── index.js │ ├── templates │ ├── .npmrc │ ├── index.js │ ├── test │ │ └── index.js │ ├── .github │ │ ├── CODE_OF_CONDUCT.md │ │ ├── SECURITY.md │ │ ├── CONTRIBUTING.md │ │ └── workflows │ │ │ └── test.yml │ ├── README.md │ └── LICENSE │ ├── bin │ └── create-package │ ├── CODE_OF_CONDUCT.md │ ├── package-support.json │ ├── LICENSE │ ├── package.json │ ├── CONTRIBUTING.md │ ├── README.md │ └── index.js ├── README.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | test/tmp 2 | node_modules 3 | -------------------------------------------------------------------------------- /.github/workflows/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @wesleytodd @rxmarbles 2 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /packages/create-pkg/templates/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Create PKG 2 | 3 | TODO: Add specificities here 4 | -------------------------------------------------------------------------------- /packages/create-pkg/bin/create-package: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict' 3 | require('../').cli()(process.argv.slice(2)) 4 | -------------------------------------------------------------------------------- /packages/create-pkg/templates/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function () { 4 | return 'Hello World' 5 | } 6 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function () { 4 | return 'Hello World' 5 | } 6 | -------------------------------------------------------------------------------- /packages/create-pkg/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | The Node.js Code of Conduct, which applies to this project, can be found at 4 | https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md. 5 | -------------------------------------------------------------------------------- /packages/create-pkg/templates/test/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const { suite, test } = require('mocha') 3 | const assert = require('assert') 4 | const pkg = require('../package.json') 5 | const mod = require('..') 6 | 7 | suite(pkg.name, () => { 8 | test('...', () => { 9 | assert(mod) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/test/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const { suite, test } = require('mocha') 3 | const assert = require('assert') 4 | const pkg = require('../package.json') 5 | const mod = require('..') 6 | 7 | suite(pkg.name, () => { 8 | test('...', () => { 9 | assert(mod) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - directory: / 4 | package-ecosystem: github-actions 5 | rebase-strategy: auto 6 | schedule: 7 | interval: daily 8 | - directory: / 9 | package-ecosystem: npm 10 | rebase-strategy: auto 11 | schedule: 12 | interval: daily 13 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project as adopted the Contributor Covenant v1.4.1 as its Code of Conduct. 4 | See here for the details: 5 | 6 | https://www.contributor-covenant.org/version/1/4/code-of-conduct 7 | 8 | To report or discuss issues you can email tmp or open a public issue on GitHub. 9 | -------------------------------------------------------------------------------- /packages/create-pkg/templates/.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project as adopted the Contributor Covenant v1.4.1 as its Code of Conduct. 4 | See here for the details: 5 | 6 | https://www.contributor-covenant.org/version/1/4/code-of-conduct 7 | 8 | To report or discuss issues you can email <%- author %> or open a public issue on GitHub. 9 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | This project supports security and feature development on the two most recent 6 | major versions. It also supports all active and LTS Node.js release lines. 7 | 8 | ## Reporting a Vulnerability 9 | 10 | To report a vulnerability email tmp before opening public issues on the repo. 11 | -------------------------------------------------------------------------------- /packages/create-pkg/templates/.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | This project supports security and feature development on the two most recent 6 | major versions. It also supports all active and LTS Node.js release lines. 7 | 8 | ## Reporting a Vulnerability 9 | 10 | To report a vulnerability email <%- author %> before opening public issues on the repo. 11 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tmp", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "commonjs", 7 | "keywords": [], 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "tmp", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "mocha": "^10.3.0", 15 | "standard": "^17.1.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/create-pkg/templates/.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | :+1::tada: Welcome, thanks for taking the time to contribute! :tada::+1: 4 | 5 | [Code Of Conduct](./CODE_OF_CONDUCT.md) 6 | 7 | All contributions are welcome; features, fixes, documentation or just helping 8 | others solve their issues. The best way to get started is to look through 9 | our Issues and Pull Requests. If you have questions feel free to open an Issue 10 | and tag it with `question` so others can find it and help out! 11 | 12 | Happy Hacking! 13 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | :+1::tada: Welcome, thanks for taking the time to contribute! :tada::+1: 4 | 5 | [Code Of Conduct](./CODE_OF_CONDUCT.md) 6 | 7 | All contributions are welcome; features, fixes, documentation or just helping 8 | others solve their issues. The best way to get started is to look through 9 | our Issues and Pull Requests. If you have questions feel free to open an Issue 10 | and tag it with `question` so others can find it and help out! 11 | 12 | Happy Hacking! 13 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/README.md: -------------------------------------------------------------------------------- 1 | # tmp 2 | 3 | [![NPM Version](https://img.shields.io/npm/v/tmp.svg)](https://npmjs.org/package/tmp) 4 | [![NPM Downloads](https://img.shields.io/npm/dm/tmp.svg)](https://npmjs.org/package/tmp) 5 | [![test](https://github.com/pkgjs/__tmp/workflows/Test/badge.svg)](https://github.com/pkgjs/__tmp/actions?query=workflow%3ATest) 6 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard) 7 | 8 | 9 | 10 | ``` 11 | $ npm i tmp 12 | ``` 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pkgjs/create", 3 | "version": "1.0.0", 4 | "description": "The monorepo for all create-pkg packages", 5 | "scripts": { 6 | "test": "npm test -ws --if-present" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "git@github.com:pkgjs/create.git" 11 | }, 12 | "license": "ISC", 13 | "bugs": { 14 | "url": "https://github.com/pkgjs/create-pkg/issues" 15 | }, 16 | "homepage": "https://github.com/pkgjs/create-pkg#readme", 17 | "workspaces": [ 18 | "packages/*" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/create-pkg/templates/.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - master 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | node-version: [10.x, 12.x, 13.x, 14.x] 13 | steps: 14 | - uses: actions/checkout@v1 15 | - name: Use Node.js ${{ matrix.node-version }} 16 | uses: actions/setup-node@v1 17 | with: 18 | node-version: ${{ matrix.node-version }} 19 | - name: npm install and test 20 | run: npm it 21 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - master 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | node-version: [10.x, 12.x, 13.x, 14.x] 13 | steps: 14 | - uses: actions/checkout@v1 15 | - name: Use Node.js ${{ matrix.node-version }} 16 | uses: actions/setup-node@v1 17 | with: 18 | node-version: ${{ matrix.node-version }} 19 | - name: npm install and test 20 | run: npm it 21 | -------------------------------------------------------------------------------- /packages/create-pkg/package-support.json: -------------------------------------------------------------------------------- 1 | { 2 | "versions": [ 3 | { 4 | "version": "*", 5 | "target": { 6 | "node": "lts_active" 7 | }, 8 | "response": { 9 | "type": "time-permitting", 10 | "paid": false, 11 | "contact": { 12 | "name": "Package Maintenance Working Group", 13 | "url": "https://github.com/pkgjs/wiby/issues" 14 | } 15 | }, 16 | "backing": [ 17 | { "project": "https://github.com/nodejs" }, 18 | { "foundation": "https://openjsf.org/" } 19 | ] 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /packages/create-pkg/templates/README.md: -------------------------------------------------------------------------------- 1 | # <%- name %> 2 | 3 | [![NPM Version](https://img.shields.io/npm/v/<%- name %>.svg)](https://npmjs.org/package/<%- name %>) 4 | [![NPM Downloads](https://img.shields.io/npm/dm/<%- name %>.svg)](https://npmjs.org/package/<%- name %>) 5 | [![test](https://github.com/<%- githubOrg %>/<%- githubRepo %>/workflows/Test/badge.svg)](https://github.com/<%- githubOrg %>/<%- githubRepo %>/actions?query=workflow%3ATest) 6 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard) 7 | 8 | <%- typeof description !== 'undefined' ? description : '' %> 9 | 10 | ``` 11 | $ npm i <%- name %> 12 | ``` 13 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'main' 7 | pull_request: 8 | branches: 9 | - '*' 10 | 11 | jobs: 12 | ci: 13 | strategy: 14 | matrix: 15 | node-version: 16 | - '18' 17 | - '20' 18 | - '21' 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Checkout Repo 22 | uses: actions/checkout@v4 23 | - name: Setup Node 24 | uses: actions/setup-node@v4 25 | with: 26 | cache: npm 27 | cache-dependency-path: 'package-lock.json' 28 | - name: Install Deps 29 | run: npm ci 30 | - name: Run Tests 31 | run: npm test 32 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2024, tmp 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /packages/create-pkg/templates/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) <%- (new Date()).getFullYear() %>, <%- author %> 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /packages/create-pkg/test/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const { suite, test, before } = require('mocha') 3 | const pkg = require('../package.json') 4 | const fixtures = require('fs-test-fixtures') 5 | const createPackage = require('..') 6 | 7 | const barePrompt = { 8 | promptor: () => async (prompts) => { 9 | // Set defaults from prompts 10 | const out = await Promise.all(prompts.map(async (p) => { 11 | if (!p.when) { 12 | return [] 13 | } 14 | let ret = typeof p.default === 'function' ? p.default({}) : p.default 15 | if (ret && typeof ret.then === 'function') { 16 | ret = await ret 17 | } 18 | return [p.name, ret] 19 | })) 20 | return Object.fromEntries(out) 21 | } 22 | } 23 | 24 | suite(pkg.name, () => { 25 | let fix 26 | before(() => { 27 | fix = fixtures() 28 | }) 29 | 30 | test('scaffolds a package', async function () { 31 | await fix.setup() 32 | await createPackage({ 33 | cwd: fix.TMP, 34 | push: false, 35 | silent: true, 36 | githubRepo: '__tmp', 37 | author: 'tmp' 38 | }, barePrompt) 39 | }) 40 | }) 41 | -------------------------------------------------------------------------------- /packages/create-pkg/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Contributors https://github.com/pkgjs/create/graphs/contributors 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /packages/create-pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pkgjs/create-pkg", 3 | "version": "0.0.0", 4 | "description": "Scaffold a package", 5 | "author": "Wes Todd ", 6 | "keywords": [ 7 | "scaffold", 8 | "package", 9 | "git", 10 | "module", 11 | "package.json", 12 | "readme", 13 | "mocha", 14 | "standard" 15 | ], 16 | "license": "ISC", 17 | "main": "index.js", 18 | "bin": { 19 | "create-package": "bin/create-package" 20 | }, 21 | "scripts": { 22 | "test": "standard && mocha --timeout=60000", 23 | "test:debug": "mocha --inspect --inspect-brk --timeout=0", 24 | "release": "npm t && standard-version && npm publish", 25 | "postpublish": "git push origin && git push origin --tags" 26 | }, 27 | "dependencies": { 28 | "cptmpl": "0.0.5", 29 | "create-git": "^1.0.0-2", 30 | "create-package-json": "^1.0.0-2", 31 | "loggerr": "^3.0.0-3", 32 | "opta": "0.0.6", 33 | "semver": "^7.3.2" 34 | }, 35 | "devDependencies": { 36 | "fs-extra": "^8.0.1", 37 | "fs-test-fixtures": "^0.1.3", 38 | "mocha": "^6.2.2", 39 | "standard": "^17.1.0", 40 | "standard-version": "^9.0.0" 41 | }, 42 | "support": true 43 | } 44 | -------------------------------------------------------------------------------- /packages/create-pkg/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Code of Conduct 4 | 5 | The Node.js project has a 6 | [Code of Conduct](https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md) 7 | to which all contributors must adhere. 8 | 9 | See [details on our policy on Code of Conduct](https://github.com/nodejs/node/blob/master/doc/contributing/code-of-conduct.md). 10 | 11 | 12 | ## Developer's Certificate of Origin 1.1 13 | 14 | By making a contribution to this project, I certify that: 15 | 16 | * (a) The contribution was created in whole or in part by me and I 17 | have the right to submit it under the open source license 18 | indicated in the file; or 19 | 20 | * (b) The contribution is based upon previous work that, to the best 21 | of my knowledge, is covered under an appropriate open source 22 | license and I have the right under that license to submit that 23 | work with modifications, whether created in whole or in part 24 | by me, under the same open source license (unless I am 25 | permitted to submit under a different license), as indicated 26 | in the file; or 27 | 28 | * (c) The contribution was provided directly to me by some other 29 | person who certified (a), (b) or (c) and I have not modified 30 | it. 31 | 32 | * (d) I understand and agree that this project and the contribution 33 | are public and that a record of the contribution (including all 34 | personal information I submit with it, including my sign-off) is 35 | maintained indefinitely and may be redistributed consistent with 36 | this project or the open source license(s) involved. 37 | -------------------------------------------------------------------------------- /packages/create-pkg/README.md: -------------------------------------------------------------------------------- 1 | # Scaffold a Package 2 | 3 | [![NPM Version](https://img.shields.io/npm/v/create-pkg.svg)](https://npmjs.org/package/create-pkg) 4 | [![NPM Downloads](https://img.shields.io/npm/dm/create-pkg.svg)](https://npmjs.org/package/create-pkg) 5 | [![test](https://github.com/pkgjs/create/workflows/Test/badge.svg)](https://github.com/pkgjs/create/actions?query=workflow%3ATest) 6 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard) 7 | 8 | ## Usage 9 | 10 | ``` 11 | $ npm init pkg 12 | 13 | # or 14 | 15 | $ npx create-pkg 16 | 17 | # or 18 | 19 | $ npm install -g create-pkg 20 | $ create-pkg 21 | ``` 22 | 23 | ### CLI Usage 24 | 25 | ``` 26 | $ create-pkg --help 27 | create-git 28 | 29 | initalize a package 30 | 31 | Options: 32 | --help Show help [boolean] 33 | --version Show version number [boolean] 34 | --cwd, -d Directory to run in [default: process.cwd()] 35 | # TODO 36 | ``` 37 | 38 | ### Programmatic Usage 39 | 40 | ```javascript 41 | const createPkg = require('@pkgjs/create-pkg') 42 | 43 | await createPkg({ 44 | // TODO 45 | }) 46 | ``` 47 | 48 | #### Composition with other `create-*` packages 49 | 50 | This generator is built on top of `opta`, a helper library for collecting 51 | user input from multiple interfaces: CLI via `yargs`, interactive prompts via `inquirer` 52 | and via a JS interface. To compose with other `opta` based input collection, 53 | you can use `.options` to access the cli/prompt/js configurations. 54 | 55 | ```javascript 56 | const createPkg = require('create-pkg') 57 | const opta = require('opta') 58 | 59 | const opts = opta({ 60 | commandDescription: 'Your description', 61 | options: { 62 | // Spread the options from createGPkg 63 | ...createPkg.options, 64 | } 65 | }) 66 | 67 | // Our generator main 68 | module.exports = async function (input) { 69 | // Add our input as overrides on the opta instance 70 | options.overrides(input) 71 | 72 | // Prompt the user, 73 | await options.prompt() 74 | 75 | // Get the current values from the opta instance 76 | let opts = options.values() 77 | 78 | // Call create git 79 | await createPkg(opts) 80 | } 81 | ``` 82 | 83 | For more information check out the [docs for `opta`](https://www.npmjs.com/package/opta). 84 | -------------------------------------------------------------------------------- /packages/create-pkg/test/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | # default 2 | package-lock.json 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | lerna-debug.log* 11 | .pnpm-debug.log* 12 | 13 | # Diagnostic reports (https://nodejs.org/api/report.html) 14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | *.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | *.lcov 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | node_modules/ 46 | jspm_packages/ 47 | 48 | # Snowpack dependency directory (https://snowpack.dev/) 49 | web_modules/ 50 | 51 | # TypeScript cache 52 | *.tsbuildinfo 53 | 54 | # Optional npm cache directory 55 | .npm 56 | 57 | # Optional eslint cache 58 | .eslintcache 59 | 60 | # Optional stylelint cache 61 | .stylelintcache 62 | 63 | # Microbundle cache 64 | .rpt2_cache/ 65 | .rts2_cache_cjs/ 66 | .rts2_cache_es/ 67 | .rts2_cache_umd/ 68 | 69 | # Optional REPL history 70 | .node_repl_history 71 | 72 | # Output of 'npm pack' 73 | *.tgz 74 | 75 | # Yarn Integrity file 76 | .yarn-integrity 77 | 78 | # dotenv environment variable files 79 | .env 80 | .env.development.local 81 | .env.test.local 82 | .env.production.local 83 | .env.local 84 | 85 | # parcel-bundler cache (https://parceljs.org/) 86 | .cache 87 | .parcel-cache 88 | 89 | # Next.js build output 90 | .next 91 | out 92 | 93 | # Nuxt.js build / generate output 94 | .nuxt 95 | dist 96 | 97 | # Gatsby files 98 | .cache/ 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* -------------------------------------------------------------------------------- /packages/create-pkg/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const opta = require('opta') 4 | const createPackageJson = require('create-package-json') 5 | const createGit = require('create-git') 6 | const cptmpl = require('cptmpl') 7 | const { Loggerr } = require('loggerr') 8 | 9 | function initOpts () { 10 | return opta({ 11 | commandDescription: 'Generate a package.json', 12 | options: { 13 | cwd: { 14 | description: 'Directory to run in', 15 | prompt: false, 16 | flag: { 17 | alias: 'd', 18 | defaultDescription: 'process.cwd()' 19 | } 20 | }, 21 | 22 | silent: { 23 | type: 'boolean', 24 | prompt: false, 25 | flag: { 26 | conflicts: ['verbose'] 27 | } 28 | }, 29 | verbose: { 30 | type: 'boolean', 31 | prompt: false, 32 | flag: { 33 | conflicts: ['silent'] 34 | } 35 | }, 36 | 37 | // First ask the package questions 38 | ...createPackageJson.options, 39 | 40 | // Add our additional prompts 41 | githubOrg: { 42 | default: 'pkgjs', 43 | prompt: { 44 | message: 'GitHub User/Org:' 45 | } 46 | }, 47 | githubRepo: { 48 | flag: { 49 | key: 'github-repo' 50 | }, 51 | prompt: { 52 | message: 'GitHub repo:', 53 | default: (promptInput, allInput) => { 54 | // Remove the scope from the package name 55 | return allInput.name && allInput.name.replace(/^@[^/]+\//, '') 56 | } 57 | } 58 | }, 59 | 60 | ...createGit.options, 61 | 62 | // Override createGit.options.remoteOrigin 63 | remoteOrigin: { 64 | ...createGit.options.remoteOrigin, 65 | prompt: { 66 | ...createGit.options.remoteOrigin.prompt, 67 | default: (promptInput, allInput) => { 68 | return `git@github.com:${allInput.githubOrg}/${allInput.githubRepo}.git` 69 | } 70 | } 71 | } 72 | } 73 | }) 74 | } 75 | 76 | module.exports = main 77 | async function main (input, _opts = {}) { 78 | const options = initOpts() 79 | options.overrides({ 80 | ...input, 81 | cwd: input.cwd || process.cwd(), 82 | 83 | // My opinionated overrides 84 | version: '0.0.0', 85 | devDependencies: ['standard', 'mocha'], 86 | additionalRules: ['package-lock.json'] 87 | }) 88 | 89 | let opts = options.values() 90 | 91 | const log = _opts.logger || new Loggerr({ 92 | level: (opts.silent && 'silent') || (opts.verbose && 'debug') || 'info', 93 | formatter: 'cli' 94 | }) 95 | 96 | await options.prompt({ 97 | promptor: _opts.promptor 98 | })() 99 | 100 | opts = options.values() 101 | 102 | // do stuff 103 | await cptmpl.recursive(tmplPath(), opts.cwd, opts) 104 | await createPackageJson(opts, { 105 | promptor: _opts.promptor, 106 | logger: log 107 | }) 108 | await createGit(opts, { 109 | promptor: _opts.promptor, 110 | logger: log 111 | }) 112 | } 113 | 114 | function tmplPath (...args) { 115 | return path.join(__dirname, 'templates', ...args) 116 | } 117 | 118 | module.exports.options = initOpts().options 119 | module.exports.cli = function () { 120 | return initOpts().cli((yargs) => { 121 | yargs.command('$0', 'Generate a package', () => {}, main) 122 | }) 123 | } 124 | --------------------------------------------------------------------------------