Skip to content

Commit

Permalink
Merge branch 'main' into update/vc-dev-repo-root2
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Jul 19, 2023
2 parents ba5fb64 + ce4633f commit f2351a8
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .changeset/sixty-buttons-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@vercel/frameworks': minor
'@vercel/static-build': patch
---

Add `ignorePackageJsonScript` configuration for Framework command settings to ignore the `package.json` script.

Enable this mode for Storybook's `buildCommand`, since it should not invoke the "build" script, which is most likely designated for the frontend app build.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"orgId": ".",
"projectId": ".",
"settings": {
"framework": "storybook",
"buildCommand": "npm run build-storybook",
"outputDirectory": "storybook-static"
"framework": "storybook"
}
}
1 change: 1 addition & 0 deletions packages/frameworks/src/frameworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,7 @@ export const frameworks = [
},
buildCommand: {
value: 'storybook build',
ignorePackageJsonScript: true,
},
devCommand: {
value: `storybook dev -p $PORT`,
Expand Down
15 changes: 14 additions & 1 deletion packages/frameworks/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,24 @@ export interface SettingPlaceholder {

export interface SettingValue {
/**
* A predefined setting for the detected framework
* A predefined setting for the detected framework.
* @example "next dev --port $PORT"
*/
value: string | null;
/**
* Placeholder text that may be shown in the UI when
* the user is configuring this setting value.
* @example "`npm run build` or `next build`"
*/
placeholder?: string;
/**
* When set to `true`, then the builder will not
* invoke the equivalent script in `package.json`,
* and instead will invoke the command specified in
* configuration setting directly. When this
* configuration is enabled, `value` must be a string.
*/
ignorePackageJsonScript?: boolean;
}

export type Setting = SettingValue | SettingPlaceholder;
Expand Down
16 changes: 16 additions & 0 deletions packages/frameworks/test/frameworks.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ const SchemaSettings = {
},
},
},
{
type: 'object',
required: ['value', 'ignorePackageJsonScript'],
additionalProperties: false,
properties: {
value: {
type: 'string',
},
placeholder: {
type: 'string',
},
ignorePackageJsonScript: {
type: 'boolean',
},
},
},
{
type: 'object',
required: ['placeholder'],
Expand Down
6 changes: 5 additions & 1 deletion packages/static-build/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ function getCommand(
return propValue;
}

if (pkg) {
const ignorePackageJsonScript =
name === 'build' &&
framework?.settings.buildCommand.ignorePackageJsonScript;

if (pkg && !ignorePackageJsonScript) {
const scriptName = getScriptName(pkg, name, config);

if (hasScript(scriptName, pkg)) {
Expand Down

0 comments on commit f2351a8

Please sign in to comment.