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

Add preview mode #399

Merged
merged 26 commits into from Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f4f3bf2
Add preview mode
TiagoDanin May 3, 2019
263cf7f
Improve preview mode
TiagoDanin May 4, 2019
3e15b54
Show of commands in preview mode
TiagoDanin May 5, 2019
d379cea
Show correct package manager name
TiagoDanin Jul 8, 2019
732b807
Merge branch 'master' into preview.mode
TiagoDanin Jul 8, 2019
643e1ae
Documentation --preview
TiagoDanin Jul 22, 2019
194e908
Merge branch 'preview.mode' of github.com:TiagoDanin-Forks/np into pr…
TiagoDanin Jul 22, 2019
a59eda3
Update Why section in README
TiagoDanin Aug 3, 2019
43eb8fe
Fix, add two newlines before the next section
TiagoDanin Aug 3, 2019
a47c28b
Replace "Release page" ~> "Releases draft"
TiagoDanin Sep 14, 2019
08c90bd
Use label "[Preview]"
TiagoDanin Sep 14, 2019
341b73c
Merge branch 'master' into preview.mode
TiagoDanin Sep 14, 2019
3a2da0a
Show registry
TiagoDanin Sep 14, 2019
bd13963
Merge branch 'master' into preview.mode
TiagoDanin Dec 25, 2019
d96527d
Improve preview mode description
TiagoDanin Dec 25, 2019
9d79205
Improve preview mode description (by sindresorhus)
TiagoDanin Jan 11, 2020
7037382
Improve preview mode show commands
TiagoDanin Jan 11, 2020
6a48265
Revert show registry (3a2da0a954104e13123e3dcabee19377ddbe0bdd)
TiagoDanin Jan 11, 2020
c5dbe96
Merge branch 'master' into preview.mode
TiagoDanin Jan 11, 2020
4b954c3
Remove flag --otp of enabling two-factor authentication in preview mode
TiagoDanin Jan 11, 2020
9aad90b
Show full command
TiagoDanin Feb 8, 2020
a30621c
v5.2.2
TiagoDanin Feb 8, 2020
8161434
Show full command
TiagoDanin Feb 8, 2020
ab5514c
Merge branch 'master' into preview.mode
TiagoDanin Feb 9, 2020
c70fa38
Update publish.js
sindresorhus Feb 22, 2020
268aeb4
Update index.js
sindresorhus Feb 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions source/cli.js
Expand Up @@ -25,6 +25,7 @@ const cli = meow(`
--no-cleanup Skips cleanup of node_modules
--yolo Skips cleanup and testing
--no-publish Skips publishing
--preview Skips publishing and pushing
TiagoDanin marked this conversation as resolved.
Show resolved Hide resolved
--tag Publish under a given dist-tag
--no-yarn Don't use Yarn
--contents Subdirectory to publish
Expand Down Expand Up @@ -63,6 +64,9 @@ const cli = meow(`
},
contents: {
type: 'string'
},
preview: {
type: 'boolean'
}
}
});
Expand All @@ -75,6 +79,7 @@ updateNotifier({pkg: cli.pkg}).notify();
const defaultFlags = {
cleanup: true,
publish: true,
preview: false,
TiagoDanin marked this conversation as resolved.
Show resolved Hide resolved
yarn: hasYarn()
};

Expand Down
19 changes: 14 additions & 5 deletions source/index.js
Expand Up @@ -38,6 +38,7 @@ module.exports = async (input = 'patch', options) => {
options = {
cleanup: true,
publish: true,
preview: false,
TiagoDanin marked this conversation as resolved.
Show resolved Hide resolved
...options
};

Expand All @@ -63,7 +64,9 @@ module.exports = async (input = 'patch', options) => {
let isPublished = false;

const rollback = onetime(async () => {
console.log('\nPublish failed. Rolling back to the previous state…');
if (!options.preview) {
console.log('\nPublish failed. Rolling back to the previous state…');
}

const tagVersionPrefix = await util.getTagVersionPrefix(options);

Expand Down Expand Up @@ -128,7 +131,7 @@ module.exports = async (input = 'patch', options) => {
},
{
title: 'Installing dependencies using npm',
enabled: () => options.yarn === false,
TiagoDanin marked this conversation as resolved.
Show resolved Hide resolved
enabled: () => !options.yarn,
task: () => {
const args = hasLockFile ? ['ci'] : ['install', '--no-package-lock', '--no-production'];
return exec('npm', args);
Expand All @@ -141,7 +144,7 @@ module.exports = async (input = 'patch', options) => {
tasks.add([
{
title: 'Running tests using npm',
enabled: () => options.yarn === false,
enabled: () => !options.yarn,
task: () => exec('npm', ['test'])
},
{
Expand All @@ -163,12 +166,12 @@ module.exports = async (input = 'patch', options) => {
tasks.add([
{
title: 'Bumping version using Yarn',
enabled: () => options.yarn === true,
enabled: () => options.yarn,
task: () => exec('yarn', ['version', '--new-version', input])
},
{
title: 'Bumping version using npm',
enabled: () => options.yarn === false,
enabled: () => !options.yarn,
task: () => exec('npm', ['version', input])
}
]);
Expand All @@ -177,6 +180,7 @@ module.exports = async (input = 'patch', options) => {
tasks.add([
{
title: `Publishing package using ${pkgManagerName}`,
skip: () => options.preview,
itaisteinherz marked this conversation as resolved.
Show resolved Hide resolved
task: (context, task) => {
let hasError = false;

Expand All @@ -199,6 +203,7 @@ module.exports = async (input = 'patch', options) => {
tasks.add([
{
title: 'Enabling two-factor authentication',
skip: () => options.preview,
task: (context, task) => enable2fa(task, pkg.name, {otp: context.otp})
}
]);
Expand All @@ -208,6 +213,10 @@ module.exports = async (input = 'patch', options) => {
tasks.add({
title: 'Pushing tags',
skip: async () => {
if (options.preview) {
return 'Preview Mode';
}

if (!(await git.hasUpstream())) {
return 'Upstream branch not found; not pushing.';
}
Expand Down