Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: form8ion/javascript-scaffolder
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v11.16.0
Choose a base ref
...
head repository: form8ion/javascript-scaffolder
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v11.17.0
Choose a head ref
  • 1 commit
  • 7 files changed
  • 1 contributor

Commits on Dec 6, 2020

  1. feat(sub-project): prevented defining the node version differently th…

    …an the parent project
    travi committed Dec 6, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    travi Matt Travi
    Copy the full SHA
    d9ecc2d View commit details
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
"test:integration:base": "cucumber-js test/integration --profile base",
"test:integration:debug": "DEBUG=test run-s test:integration",
"test:integration:wip": "run-s 'test:integration:base -- --profile wip'",
"test:integration:focus": "run-s 'test:integration:base -- --profile focus'",
"test:integration:focus": "NODE_OPTIONS=--enable-source-maps run-s 'test:integration:base -- --profile focus'",
"coverage:report": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"pregenerate:md": "run-s build:js",
"generate:md": "remark . --output",
6 changes: 5 additions & 1 deletion src/node-version/scaffolder-test.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ suite('node-version scaffolder', () => {

teardown(() => sandbox.restore());

test('that mvn is configured with the desired version', async () => {
test('that nvm is configured with the desired version', async () => {
const nodeVersionCategory = any.word();
const version = any.word();
nodeVersionTasks.determineLatestVersionOf.withArgs(nodeVersionCategory).resolves(version);
@@ -28,4 +28,8 @@ suite('node-version scaffolder', () => {
assert.calledWith(nodeVersionTasks.install, nodeVersionCategory);
assert.calledWith(fsPromises.writeFile, `${projectRoot}/.nvmrc`, version);
});

test('that `undefined` is returned when a category is not defined', async () => {
assert.isUndefined(await scaffoldNodeVersion({projectRoot}));
});
});
2 changes: 2 additions & 0 deletions src/node-version/scaffolder.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@ import {info} from '@travi/cli-messages';
import {determineLatestVersionOf, install as installNodeVersion} from './tasks';

export default async function ({projectRoot, nodeVersionCategory}) {
if (!nodeVersionCategory) return undefined;

const lowerCaseCategory = nodeVersionCategory.toLowerCase();
info(`Configuring ${lowerCaseCategory} version of node`);

28 changes: 23 additions & 5 deletions src/prompts/questions-test.js
Original file line number Diff line number Diff line change
@@ -35,7 +35,9 @@ suite('prompts', () => {
sandbox.stub(commonPrompts, 'questions');

visibilityFilterForChoices.default.withArgs({}).returns({});
commonPrompts.questions.withArgs({vcs, ciServices, visibility, pathWithinParent}).returns(commonQuestions);
commonPrompts.questions
.withArgs({vcs, ciServices, visibility, pathWithinParent: undefined})
.returns(commonQuestions);
});

teardown(() => sandbox.restore());
@@ -122,7 +124,7 @@ suite('prompts', () => {
.resolves(answers);

assert.deepEqual(
await prompt({}, ciServices, hosts, visibility, vcs, decisions, pathWithinParent),
await prompt({}, ciServices, hosts, visibility, vcs, decisions),
{...answers, [questionNames.TRANSPILE_LINT]: true}
);
});
@@ -135,7 +137,7 @@ suite('prompts', () => {
prompts.prompt.resolves({...answers, [questionNames.TRANSPILE_LINT]: false});

assert.deepEqual(
await prompt({}, ciServices, {}, visibility, vcs, decisions, pathWithinParent),
await prompt({}, ciServices, {}, visibility, vcs, decisions),
{...answers, [questionNames.TRANSPILE_LINT]: false}
);
});
@@ -147,7 +149,7 @@ suite('prompts', () => {
npmConf.default.returns({get});
prompts.prompt.resolves(answers);

await prompt({npmAccount, author}, ciServices, {}, visibility, vcs, null, pathWithinParent);
await prompt({npmAccount, author}, ciServices, {}, visibility, vcs);

assert.calledWith(
prompts.prompt,
@@ -175,6 +177,22 @@ suite('prompts', () => {
);
});

test('that sub-projects are not asked about node version since the parent project already defines', async () => {
execa.default.withArgs('npm', ['whoami']).resolves({stdout: any.word()});
npmConf.default.returns({get: () => undefined});
commonPrompts.questions
.withArgs({vcs, ciServices, visibility: 'Private', pathWithinParent})
.returns(commonQuestions);
prompts.prompt.resolves(answers);

await prompt({}, ciServices, {}, 'Private', vcs, null, pathWithinParent);

assert.neverCalledWith(
prompts.prompt,
sinon.match(value => 1 === value.filter(question => questionNames.NODE_VERSION_CATEGORY === question.name).length)
);
});

test('that private packages are not asked about whether they should be scoped', async () => {
execa.default.withArgs('npm', ['whoami']).resolves({stdout: any.word()});
npmConf.default.returns({get: () => undefined});
@@ -191,7 +209,7 @@ suite('prompts', () => {
);
});

test('that no logged in user is handled gracefully', async () => {
test('that no logged-in-user is handled gracefully', async () => {
execa.default.withArgs('npm', ['whoami']).rejects();
npmConf.default.returns({get: () => undefined});
commonPrompts.questions
4 changes: 2 additions & 2 deletions src/prompts/questions.js
Original file line number Diff line number Diff line change
@@ -46,13 +46,13 @@ export async function prompt({npmAccount, author}, ciServices, hosts, visibility
}

const answers = await promptWithInquirer([
{
...pathWithinParent ? [] : [{
name: questionNames.NODE_VERSION_CATEGORY,
message: 'What node.js version should be used?',
type: 'list',
choices: ['LTS', 'Latest'],
default: 'LTS'
},
}],
{
name: questionNames.PROJECT_TYPE,
message: 'What type of JavaScript project is this?',
1 change: 1 addition & 0 deletions test/integration/features/monorepo.feature
Original file line number Diff line number Diff line change
@@ -8,3 +8,4 @@ Feature: Monorepo
And nvm is properly configured
When the project is scaffolded
Then the repository details include the path within the parent project
And project-level tools are not installed for a sub-project
8 changes: 7 additions & 1 deletion test/integration/features/step_definitions/monorepo-steps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import {Given} from 'cucumber';
import {fileExists} from '@form8ion/core';
import {Given, Then} from 'cucumber';
import any from '@travi/any';
import {assert} from 'chai';

Given('the package will be added to an existing monorepo', async function () {
this.pathWithinParent = any.string();
this.ciAnswer = null;
});

Then('project-level tools are not installed for a sub-project', async function () {
assert.isFalse(await fileExists(`${process.cwd()}/.nvmrc`));
});