Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ $ yarn add clean-publish --dev
- `access` - whether the npm registry publishes this package as a public package, or restricted
- `before-script` - run script on the to-release dir before `npm publish`
- `temp-dir` - create temporary directory with given name.
- `stage` - publish as a staged package (i.e. `npm stage publish`)

```sh
$ npx clean-publish --files "file1.js, file2.js" --fields "scripts, name"
Expand Down
3 changes: 3 additions & 0 deletions clean-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const HELP =
' --before-script Run script on the to-release dir before npm\n' +
' publish\n' +
' --temp-dir Create temporary directory with given name\n' +
' --stage Publish as a staged package (i.e. `npm stage publish`)\n' +
' -- Pass next arguments as package manager options'

const DEFAULT_OPTIONS = {
Expand Down Expand Up @@ -86,6 +87,8 @@ async function handleOptions() {
} else if (process.argv[i] === '--temp-dir') {
options.tempDir = process.argv[i + 1]
i += 1
} else if (process.argv[i] === '--stage') {
options.stage = true
} else if (process.argv[i] === '--') {
options.packageManagerOptions = process.argv.slice(i + 1)
break
Expand Down
5 changes: 3 additions & 2 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ export async function copyFiles(tempDir, filter) {

export async function publish(
cwd,
{ access, dryRun, packageManager, packageManagerOptions = [], tag }
{ access, dryRun, packageManager, packageManagerOptions = [], tag, stage }
) {
const args = ['publish', ...packageManagerOptions]
const commands = stage ? ['stage', 'publish'] : ['publish']
const args = [...commands, ...packageManagerOptions]
if (access) args.push('--access', access)
if (tag) args.push('--tag', tag)
if (dryRun) args.push('--dry-run')
Expand Down
21 changes: 10 additions & 11 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"additionalProperties": false,
"properties": {
"access": {
"$ref": "#/definitions/PackageAccess",
"description": "Whether the npm registry publishes this package as a public package, or restricted."
"description": "Whether the npm registry publishes this package as a public package, or restricted.",
"type": "string"
},
"beforeScript": {
"description": "Run script on the to-release dir before npm publish.",
Expand Down Expand Up @@ -50,9 +50,9 @@
"type": "array"
},
"packageManager": {
"$ref": "#/definitions/PackageManager",
"default": "npm",
"description": "Name of package manager to use."
"description": "Name of package manager to use.",
"type": "string"
},
"packageManagerOptions": {
"description": "Options which are directly passed into package manager during publish.",
Expand All @@ -61,6 +61,11 @@
},
"type": "array"
},
"stage": {
"default": false,
"description": "Publish as a staged package (i.e. `npm stage publish`).",
"type": "boolean"
},
"tag": {
"description": "Registers the package with the given tag.",
"type": "string"
Expand All @@ -76,12 +81,6 @@
}
},
"type": "object"
},
"PackageAccess": {
"type": "string"
},
"PackageManager": {
"type": "string"
}
}
}
}
6 changes: 6 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ export interface Config {
* Run script on the to-release dir before npm publish.
*/
beforeScript?: string

/**
* Publish as a staged package (i.e. `npm stage publish`).
* @default false
*/
stage?: boolean
}