Skip to content
New issue

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

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

Already on GitHub? # to your account

Remove tunnel flags #694

Merged
merged 12 commits into from
Dec 14, 2022
Merged

Remove tunnel flags #694

merged 12 commits into from
Dec 14, 2022

Conversation

paulelliott
Copy link
Member

@paulelliott paulelliott commented Dec 9, 2022

This cleans out all the deprecated flags related to tunnel builds.

Fixes IN-712

@paulelliott paulelliott self-assigned this Dec 9, 2022
@linear
Copy link

linear bot commented Dec 9, 2022

IN-712 Remove tunnel flags from CLI

The following flags are related to the tunnel service and are no longer needed in the CLI. These should all be removed.

  • --script-name, -s
  • --exec, -e
  • --do-not-start, -S
  • --storybook-port, -p
  • --storybook-https
  • --storybook-cert
  • --storybook-key
  • --storybook-ca
  • --storybook-url, -u

In addition, the CHROMATIC_CREATE_TUNNEL and CHROMATIC_TUNNEL_URL environment variables can be removed.

@paulelliott paulelliott requested review from tmeasday and removed request for codykaup December 9, 2022 21:57
@paulelliott
Copy link
Member Author

@ghengeveld @tmeasday Can one of you smoke test these changes locally?

const diagnostics = getInput('diagnostics');
const debug = getInput('debug');
const storybookPort = getInput('storybookPort');
const storybookUrl = getInput('storybookUrl');
Copy link
Member

@ghengeveld ghengeveld Dec 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to reintroduce storybookUrl at some point (not using the tunnel) because it's quite useful for quickly testing a random Storybook published somewhere (even if not on Chromatic).

Copy link
Member

@ghengeveld ghengeveld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

action.yml Outdated
required: false
storybookPort:
description: 'What port is your Storybook running on (auto detected from -s, if set)'
required: false
storybookUrl:
description: 'Storybook is already running at (external) url (implies -S)'
required: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed storybookUrl here.

Comment on lines 173 to 176
// TurboSnap requires a static build with a webpack stats file.
if (options.onlyChanged) throw new Error(invalidOnlyChanged());

// Start Storybook on localhost and generate the URL to it
if (!storybookUrl) {
if (exec && !port) {
throw new Error(missingStorybookPort());
}

if (!exec && (!port || !noStart)) {
// If you don't provide a port or we need to start the command, let's look up the script for it
scriptName = scriptName || 'storybook';
const storybookScript = packageJson.scripts && packageJson.scripts[scriptName];

if (!storybookScript) {
throw new Error(missingScriptName(scriptName));
}

options.https =
options.https ||
(getStorybookConfiguration(storybookScript, '--https') && {
cert: resolveHomeDir(getStorybookConfiguration(storybookScript, '--ssl-cert')),
key: resolveHomeDir(getStorybookConfiguration(storybookScript, '--ssl-key')),
ca: resolveHomeDir(getStorybookConfiguration(storybookScript, '--ssl-ca')),
});

port = port || getStorybookConfiguration(storybookScript, '-p', '--port');
if (!port) {
throw new Error(unknownStorybookPort(scriptName));
}

if (log) log.info('', inferredOptions({ scriptName, port }));
}

storybookUrl = `${options.https ? 'https' : 'http'}://localhost:${port}`;
}

return {
...options,
noStart,
useTunnel: true,
url: storybookUrl,
scriptName,
};
return options;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are unreachable after the throw above.

The check for onlyChanged was there because it's incompatible with starting Storybook rather than using a built Storybook. We can remove this check because we already check for the existence of the stats file and will just bail with missingStatsFile if it doesn't exist, and continue running the build regardless.

Comment on lines 153 to 156
// Build Storybook
if (storybookBuildDir) {
return { ...options };
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Build Storybook
if (storybookBuildDir) {
return { ...options };
}
// Use prebuilt Storybook
if (storybookBuildDir) {
return options;
}
// Look for a build-storybook script to build Storybook ourselves

Comment on lines 26 to 30
export const runPatchBuild = (runBuild: typeof runUploadBuild) => [
prepareWorkspace,
...runBuild,
restoreWorkspace,
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const runPatchBuild = (runBuild: typeof runUploadBuild) => [
prepareWorkspace,
...runBuild,
restoreWorkspace,
];
export const runPatchBuild = [
prepareWorkspace,
...runUploadBuild,
restoreWorkspace,
];

Comment on lines 33 to 34
const tasks =
options.patchHeadRef && options.patchBaseRef ? runPatchBuild(runUploadBuild) : runUploadBuild;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const tasks =
options.patchHeadRef && options.patchBaseRef ? runPatchBuild(runUploadBuild) : runUploadBuild;
const tasks =
options.patchHeadRef && options.patchBaseRef ? runPatchBuild : runUploadBuild;

@paulelliott
Copy link
Member Author

@ghengeveld Thanks for the suggestions! All updates completed.

@paulelliott paulelliott merged commit c524dea into main Dec 14, 2022
@paulelliott paulelliott deleted the remove-tunnel-flags branch December 14, 2022 18:21
@tmeasday
Copy link
Member

🚀

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants