Skip to content

Commit

Permalink
fix(deps): upgrade to pre-releases of the project and js plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Jan 27, 2025
1 parent c5a253f commit 1ec8265
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 31 deletions.
3 changes: 2 additions & 1 deletion example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import stubbedFs from 'mock-fs';
import * as td from 'testdouble';
import any from '@travi/any';

// remark-usage-ignore-next 12
// remark-usage-ignore-next 13
const stubbedNodeModules = stubbedFs.load(resolve('node_modules'));
const error = new Error('Command failed with exit code 1: npm ls husky --json');
error.exitCode = 1;
Expand All @@ -18,6 +18,7 @@ td.when(execa('. ~/.nvm/nvm.sh && nvm install', {shell: true})).thenReturn({stdo
td.when(execa('npm', ['ls', 'husky', '--json'])).thenReject(error);
td.when(execa('npm run generate:md && npm test', {shell: true})).thenReturn({stdout: {pipe: () => undefined}});
td.when(execa('npm', ['whoami'])).thenResolve({stdout: any.word()});
td.when(execa('npm', ['--version'])).thenResolve({stdout: any.word()});

const {packageManagers} = await import('@form8ion/javascript-core');
const githubPlugin = await import('@form8ion/github');
Expand Down
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
"dependencies": {
"@form8ion/config-file": "^1.1.2",
"@form8ion/core": "^4.7.1",
"@form8ion/javascript": "^13.0.2",
"@form8ion/javascript": "^14.0.0-beta.1",
"@form8ion/javascript-core": "^12.0.0",
"@form8ion/project": "^20.0.0",
"@form8ion/project": "^21.0.0-beta.1",
"deepmerge": "^4.2.2"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions src/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export default async function ({projectRoot, scope, projectName}) {

return {
scripts: {'lint:js': 'eslint .'},
dependencies: [`@form8ion/${projectName}`],
devDependencies: [`@${scope}/eslint-config`],
dependencies: {javascript: {production: [`@form8ion/${projectName}`], development: [`@${scope}/eslint-config`]}},
nextSteps: [
{summary: 'Save the extended `@form8ion` eslint-config as an exact version'},
{summary: 'Document saving this config using the dev flag'},
Expand Down
6 changes: 3 additions & 3 deletions src/scaffold.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('scaffold', () => {
const configShortName = any.word();
const projectName = `eslint-config-${configShortName}`;

const {scripts, dependencies, devDependencies, nextSteps} = await scaffold({projectRoot, projectName, scope});
const {scripts, dependencies, nextSteps} = await scaffold({projectRoot, projectName, scope});

expect(write).toHaveBeenCalledWith({
path: projectRoot,
Expand All @@ -47,8 +47,8 @@ describe('scaffold', () => {
`
);
expect(scripts).toEqual({'lint:js': 'eslint .'});
expect(dependencies).toEqual([`@form8ion/${projectName}`]);
expect(devDependencies).toEqual([`@${scope}/eslint-config`]);
expect(dependencies.javascript.production).toEqual([`@form8ion/${projectName}`]);
expect(dependencies.javascript.development).toEqual([`@${scope}/eslint-config`]);
expect(nextSteps).toEqual([
{summary: 'Save the extended `@form8ion` eslint-config as an exact version'},
{summary: 'Document saving this config using the dev flag'},
Expand Down
15 changes: 12 additions & 3 deletions test/integration/features/step_definitions/common-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import any from '@travi/any';
import {After, Before, When} from '@cucumber/cucumber';
import testDebug from 'debug';

let pluginName, extendEslintConfig, scaffoldEslintConfig, projectQuestionNames, jsQuestionNames, scaffoldJs;
let pluginName,
extendEslintConfig,
scaffoldEslintConfig,
projectQuestionNames,
jsQuestionNames,
scaffoldJs,
testForJs,
liftJs;
const __dirname = dirname(fileURLToPath(import.meta.url)); // eslint-disable-line no-underscore-dangle
const debug = testDebug('test');

Expand All @@ -35,7 +42,7 @@ Before(async function () {
pluginName = configExtender.PLUGIN_NAME;
projectQuestionNames = projectScaffolder.questionNames;
jsQuestionNames = jsPlugin.questionNames;
scaffoldJs = jsPlugin.scaffold;
({scaffold: scaffoldJs, test: testForJs, lift: liftJs} = jsPlugin);

stubbedFs({
node_modules: stubbedFs.load(resolve(__dirname, '../../../../', 'node_modules'))
Expand Down Expand Up @@ -101,7 +108,9 @@ When('the high-level scaffolder is executed', async function () {
},
configs: {eslint: {scope: `@${any.word()}`}},
decisions
})
}),
lift: liftJs,
test: testForJs
})
);
} catch (e) {
Expand Down
31 changes: 31 additions & 0 deletions test/integration/features/step_definitions/dependencies-steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {DEV_DEPENDENCY_TYPE, PROD_DEPENDENCY_TYPE} from '@form8ion/javascript-core';

import * as td from 'testdouble';
import {Then} from '@cucumber/cucumber';

function escapeSpecialCharacters(string) {
return string.replace(/[.*+?^$\-{}()|[\]\\]/g, '\\$&');
}

function assertDevDependencyIsInstalled(execa, dependencyName) {
td.verify(
execa(td.matchers.contains(
new RegExp(`(npm install|yarn add).*${escapeSpecialCharacters(dependencyName)}.*${DEV_DEPENDENCY_TYPE}`)
)),
{ignoreExtraArgs: true}
);
}

function assertProdDependencyIsInstalled(execa, dependencyName) {
td.verify(
execa(td.matchers.contains(
new RegExp(`(npm install|yarn add).*${escapeSpecialCharacters(dependencyName)}.*${PROD_DEPENDENCY_TYPE}`)
)),
{ignoreExtraArgs: true}
);
}

Then('dependencies are installed', async function () {
assertProdDependencyIsInstalled(this.execa, `@form8ion/${this.projectName}`);
assertDevDependencyIsInstalled(this.execa, `@${this.scope}/eslint-config`);
});
1 change: 1 addition & 0 deletions test/integration/features/step_definitions/npm-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Given(/^the npm cli is logged in$/, function () {

td.when(this.execa('npm run generate:md && npm test', {shell: true})).thenReturn({stdout: {pipe: () => undefined}});
td.when(this.execa('npm', ['whoami'])).thenResolve({stdout: this.npmAccount});
td.when(this.execa('npm', ['--version'])).thenResolve({stdout: any.word()});
});
1 change: 1 addition & 0 deletions test/integration/features/wrapper.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Feature: wrapper
And the npm cli is logged in
When the high-level scaffolder is executed
Then the proper form8ion config is extended
And dependencies are installed

0 comments on commit 1ec8265

Please sign in to comment.