Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make package prompts unskippable #76

Merged
merged 3 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/curly-walls-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'skuba': patch
---

**template/package:** Make prompt unskippable
11 changes: 8 additions & 3 deletions src/cli/init/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const configureFromPrompt = async (): Promise<InitConfig> => {

await cloneTemplate(templateName, destinationDir);

const { entryPoint, fields, type } = getTemplateConfig(
const { entryPoint, fields, noSkip, type } = getTemplateConfig(
path.join(process.cwd(), destinationDir),
);

Expand All @@ -174,7 +174,7 @@ export const configureFromPrompt = async (): Promise<InitConfig> => {
};
}

const shouldContinue = await confirmShouldContinue(fields);
const shouldContinue = noSkip ? true : await confirmShouldContinue(fields);

if (shouldContinue) {
log.newline();
Expand Down Expand Up @@ -255,11 +255,16 @@ const configureFromPipe = async (): Promise<InitConfig> => {

await cloneTemplate(templateName, destinationDir);

const { entryPoint, fields, type } = getTemplateConfig(
const { entryPoint, fields, noSkip, type } = getTemplateConfig(
path.join(process.cwd(), destinationDir),
);

if (!templateComplete) {
if (noSkip) {
log.err('Templating for', log.bold(templateName), 'cannot be skipped.');
process.exit(1);
}

return {
...result.value,
entryPoint,
Expand Down
28 changes: 17 additions & 11 deletions src/utils/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ import { ProjectType } from './manifest';

export type TemplateConfig = t.Static<typeof TemplateConfig>;

export const TemplateConfig = t.Record({
entryPoint: t.String.Or(t.Undefined),
fields: t.Array(
t.Record({
name: t.String,
message: t.String,
initial: t.String,
validate: t.Function.Or(t.Undefined),
export const TemplateConfig = t
.Record({
entryPoint: t.String.Or(t.Undefined),
fields: t.Array(
t.Record({
name: t.String,
message: t.String,
initial: t.String,
validate: t.Function.Or(t.Undefined),
}),
),
type: ProjectType.Or(t.Undefined),
})
.And(
t.Partial({
noSkip: t.Boolean.Or(t.Undefined),
}),
),
type: ProjectType.Or(t.Undefined),
});
);

export const TEMPLATE_CONFIG_FILENAME = 'skuba.template.js';

Expand Down
2 changes: 2 additions & 0 deletions template/oss-npm-package/skuba.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ module.exports = {
initial: 'This is my first module',
},
],
// `moduleName` is required for a valid `package.json`
noSkip: true,
type: 'package',
};
2 changes: 2 additions & 0 deletions template/private-npm-package/skuba.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ module.exports = {
initial: 'This is my first module',
},
],
// `moduleName` is required for a valid `package.json`
noSkip: true,
type: 'package',
};