Skip to content

Commit

Permalink
chore: bump deps, fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Jul 29, 2020
1 parent 7ba3122 commit 896b316
Show file tree
Hide file tree
Showing 6 changed files with 1,679 additions and 1,250 deletions.
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const cli = cac('lass');

cli
.command('<name>', 'Generate a new package')
.action(name => {
.action((name) => {
const folderName = name;
const targetPath = path.resolve(folderName);
console.log(`> Generating package in ${targetPath}`);
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"Imed Jaberi <imed_jebari@hotmail.fr> (https://www.3imed-jaberi.com)"
],
"dependencies": {
"cac": "^6.5.10",
"cac": "^6.6.1",
"camelcase": "^6.0.0",
"cross-spawn": "^7.0.3",
"debug": "^4.1.1",
"execa": "^4.0.2",
"execa": "^4.0.3",
"fixpack": "^3.0.6",
"github-username": "^5.0.1",
"github-username-regex": "^1.0.0",
Expand All @@ -55,19 +55,19 @@
"uppercamelcase": "^3.0.0"
},
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"ava": "^3.9.0",
"codecov": "^3.7.0",
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"ava": "^3.11.0",
"codecov": "^3.7.2",
"cross-env": "^7.0.2",
"eslint": "6.x",
"eslint": "^7.5.0",
"eslint-config-xo-lass": "^1.0.3",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"nyc": "^15.1.0",
"remark-cli": "^8.0.0",
"remark-preset-github": "^2.0.0",
"xo": "0.25"
"remark-cli": "^8.0.1",
"remark-preset-github": "^3.0.0",
"xo": "^0.32.1"
},
"engines": {
"node": ">= 10"
Expand Down
37 changes: 19 additions & 18 deletions sao.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ module.exports = {
name: {
message: 'What is the name of the new package',
default: () => process.argv[2] || ':folderName:',
validate: val => {
if (process.env.NODE_ENV === 'test' && val === 'lass') return true;
validate: (value) => {
if (process.env.NODE_ENV === 'test' && value === 'lass') return true;

return isValidNpmName(val);
return isValidNpmName(value);
}
},
description: {
message: 'How would you describe the new package',
default: `my ${superb.random()} project`,
validate: val =>
/"/.test(val) ? 'Description cannot contain double quotes' : true
validate: (value) =>
/"/.test(value) ? 'Description cannot contain double quotes' : true
},
pm: {
message: 'Choose a package manager',
Expand All @@ -71,7 +71,8 @@ module.exports = {
version: {
message: 'Choose an initial semver version',
default: conf.get('init-version') || '0.0.0',
validate: val => (semver.valid(val) ? true : 'Invalid semver version')
validate: (value) =>
semver.valid(value) ? true : 'Invalid semver version'
},
author: {
message: "What is your name (the author's)",
Expand All @@ -82,18 +83,18 @@ module.exports = {
message: "What is your email (the author's)",
default: conf.get('init-author-email') || ':gitEmail:',
store: true,
validate: val => (isEmail(val) ? true : 'Invalid email')
validate: (value) => (isEmail(value) ? true : 'Invalid email')
},
website: {
message: "What is your personal website (the author's)",
default: conf.get('init-author-url') || '',
store: true,
validate: val => (val === '' || isURL(val) ? true : 'Invalid URL')
validate: (value) => (value === '' || isURL(value) ? true : 'Invalid URL')
},
username: {
message: 'What is your GitHub username or organization',
store: true,
default: async answers => {
default: async (answers) => {
if (answers.name.indexOf('@') === 0)
return answers.name.split('/')[0].slice(1);

Expand All @@ -105,8 +106,8 @@ module.exports = {
return ':gitUser:';
}
},
validate: val =>
githubUsernameRegex.test(val) ? true : 'Invalid GitHub username'
validate: (value) =>
githubUsernameRegex.test(value) ? true : 'Invalid GitHub username'
},
repo: {
message: "What is your GitHub repository's URL",
Expand All @@ -119,10 +120,10 @@ module.exports = {
maintainCase: true
})}/${name}`;
},
validate: val => {
return isURL(val) &&
val.indexOf('https://github.com/') === 0 &&
val.lastIndexOf('/') !== val.length - 1
validate: (value) => {
return isURL(value) &&
value.indexOf('https://github.com/') === 0 &&
value.lastIndexOf('/') !== value.length - 1
? true
: 'Please include a valid GitHub.com URL without a trailing slash';
}
Expand All @@ -141,7 +142,7 @@ module.exports = {
store: true
},
threshold: {
when: answers => answers.coverage,
when: (answers) => answers.coverage,
type: 'list',
message:
'Select code coverage threshold required to pass (across lines/functions/branches)',
Expand All @@ -165,7 +166,7 @@ module.exports = {
// <https://github.com/saojs/sao/issues/59>
'node_modules/**': false
},
post: async ctx => {
post: async (ctx) => {
ctx.gitInit();

const gh = ctx.answers.repo
Expand Down Expand Up @@ -208,7 +209,7 @@ module.exports = {
ctx.answers.repo,
`https://travis-ci.com/${gh}`,
`https://codecov.io/gh/${gh}`
].map(link => console.log(`TODO: ${link}`));
].map((link) => console.log(`TODO: ${link}`));

// Fix package.json file
fixpack(`${ctx.folderPath}/package.json`);
Expand Down
10 changes: 5 additions & 5 deletions template/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ const test = require('ava');

const Script = require('..');

test.beforeEach(t => {
test.beforeEach((t) => {
const script = new Script({});
Object.assign(t.context, { script });
});

test('returns itself', t => {
test('returns itself', (t) => {
t.true(t.context.script instanceof Script);
});

test('sets a config object', t => {
test('sets a config object', (t) => {
const script = new Script(false);
t.true(script instanceof Script);
});

test('renders name', t => {
test('renders name', (t) => {
const { script } = t.context;
t.is(script.renderName(), 'script');
});

test('sets a default name', t => {
test('sets a default name', (t) => {
const { script } = t.context;
t.is(script._name, 'script');
});
30 changes: 15 additions & 15 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const defaults = {
keywords: 'boilerplate,generator npm package lass'
};

test('auto detects email address from github', async t => {
test('auto detects email address from github', async (t) => {
const stream = await sao.mockPrompt(template, {
name: 'lass',
description: 'test',
Expand All @@ -30,7 +30,7 @@ test('auto detects email address from github', async t => {
t.is(stream.meta.answers.username, 'tj');
});

test('allows GPL-3.0 license', async t => {
test('allows GPL-3.0 license', async (t) => {
const stream = await sao.mockPrompt(template, {
name: 'lass',
description: 'test',
Expand All @@ -43,7 +43,7 @@ test('allows GPL-3.0 license', async t => {
t.is(stream.meta.answers.license, 'GPL-3.0');
});

test('allows SPDX licenses', async t => {
test('allows SPDX licenses', async (t) => {
const getRandomLicense = () => {
return [...spdxLicenseList][
Math.floor(Math.random() * [...spdxLicenseList].length)
Expand All @@ -69,23 +69,23 @@ test('allows SPDX licenses', async t => {
//
// test.todo('logs error if soa fails to write license');

test('defaults', async t => {
test('defaults', async (t) => {
const stream = await sao.mockPrompt(template, {
...defaults,
name: 'my-package-name'
});

const ignoredFiles = ['yarn-error.log'];
const ignoredFiles = new Set(['yarn-error.log']);
t.snapshot(
stream.fileList.filter(path => !ignoredFiles.includes(path)),
stream.fileList.filter((path) => !ignoredFiles.has(path)),
'generated files'
);

const content = stream.fileContents('README.md');
t.snapshot(content, 'content of README.md');
});

test('username retains capital letters', async t => {
test('username retains capital letters', async (t) => {
const stream = await sao.mockPrompt(template, {
...defaults,
name: 'my-package-name',
Expand All @@ -95,48 +95,48 @@ test('username retains capital letters', async t => {
t.regex(stream.meta.answers.repo, /fooBar/);
});

test('invalid name', async t => {
test('invalid name', async (t) => {
const error = await t.throwsAsync(
sao.mockPrompt(template, { ...defaults, name: 'Foo Bar Baz Beep' })
);
t.regex(error.message, /package name cannot have uppercase letters/);
});

test('allows scope', async t => {
test('allows scope', async (t) => {
await t.notThrowsAsync(
sao.mockPrompt(template, { ...defaults, name: '@foo/bar' })
);
});

test('invalid version', async t => {
test('invalid version', async (t) => {
const error = await t.throwsAsync(
sao.mockPrompt(template, { ...defaults, version: 'abcdef' })
);
t.regex(error.message, /Invalid semver version/);
});

test('invalid email', async t => {
test('invalid email', async (t) => {
const error = await t.throwsAsync(
sao.mockPrompt(template, { ...defaults, email: 'niftylettuce' })
);
t.regex(error.message, /Invalid email/);
});

test('invalid website', async t => {
test('invalid website', async (t) => {
const error = await t.throwsAsync(
sao.mockPrompt(template, { ...defaults, website: 'niftylettuce' })
);
t.regex(error.message, /Invalid URL/);
});

test('invalid username', async t => {
test('invalid username', async (t) => {
const error = await t.throwsAsync(
sao.mockPrompt(template, { ...defaults, username: '$$$' })
);
t.regex(error.message, /Invalid GitHub username/);
});

test('invalid repo', async t => {
test('invalid repo', async (t) => {
const error = await t.throwsAsync(
sao.mockPrompt(template, {
...defaults,
Expand All @@ -150,7 +150,7 @@ test('invalid repo', async t => {
);
});

test('invalid description with double quoutes', async t => {
test('invalid description with double quoutes', async (t) => {
const error = await t.throwsAsync(
sao.mockPrompt(template, {
...defaults,
Expand Down
Loading

0 comments on commit 896b316

Please sign in to comment.