Skip to content

Commit

Permalink
feat: MIT License by default
Browse files Browse the repository at this point in the history
Adds an additional option to the CLI, somewhat unavoidable, we need the package author name to place in the LICENSE file. That said, we can double up and use the author name provided to place inside the package.json's author field as well.
  • Loading branch information
audiolion committed Oct 15, 2019
1 parent dbc3d70 commit 3bb5e4f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ prog
}

bootSpinner.start();

// copy the template
await fs.copy(
path.resolve(__dirname, `../templates/${template}`),
Expand All @@ -247,12 +248,38 @@ prog
path.resolve(projectPath, './gitignore'),
path.resolve(projectPath, './.gitignore')
);

bootSpinner.stop();

// update license year and prompt for name
let license = fs.readFileSync(
path.resolve(projectPath, 'LICENSE'),
'utf-8'
);

license = license.replace(/<year>/, `${new Date().getFullYear()}`);

const licenseInput = new Input({
name: 'author',
message: 'Who is the package author?',
});

let author = await licenseInput.run();

license = license.replace(/<author>/, author.trim());

fs.writeFileSync(path.resolve(projectPath, 'LICENSE'), license, {
encoding: 'utf-8',
});

// Install deps
process.chdir(projectPath);
const safeName = safePackageName(pkg);
const pkgJson = {
name: safeName,
version: '0.1.0',
license: 'MIT',
author: author,
main: 'dist/index.js',
module: `dist/${safeName}.esm.js`,
typings: `dist/index.d.ts`,
Expand Down
21 changes: 21 additions & 0 deletions templates/basic/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) <year> <author>

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.
21 changes: 21 additions & 0 deletions templates/react/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) <year> <author>

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.

0 comments on commit 3bb5e4f

Please sign in to comment.