Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: "pnpm publish" supports package.{json5,yaml}
ref #1803
- Loading branch information
Showing
12 changed files
with
123 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import readImporterManifest from '@pnpm/read-importer-manifest' | ||
import path = require('path') | ||
import rimraf = require('rimraf-then') | ||
import writeJsonFile = require('write-json-file') | ||
import { PnpmOptions } from '../types' | ||
import runNpm from './runNpm' | ||
|
||
export default async function ( | ||
args: string[], | ||
opts: PnpmOptions, | ||
command: string, | ||
) { | ||
if (args.length && args[0].endsWith('.tgz')) { | ||
await runNpm(['publish', ...args]) | ||
return | ||
} | ||
const prefix = args.length && args[0] || process.cwd() | ||
const { fileName, manifest, writeImporterManifest } = await readImporterManifest(prefix) | ||
const exoticManifestFormat = fileName !== 'package.json' | ||
if (exoticManifestFormat) { | ||
await rimraf(path.join(prefix, fileName)) | ||
await writeJsonFile(path.join(prefix, 'package.json'), manifest) | ||
} | ||
const { status } = await runNpm(['publish', ...opts.argv.original.slice(1)]) | ||
if (exoticManifestFormat) { | ||
await rimraf(path.join(prefix, 'package.json')) | ||
await writeImporterManifest(manifest, true) | ||
} | ||
if (status !== 0) { | ||
process.exit(status) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import { sync as runScriptSync } from '../runScript' | ||
|
||
export default function runNpm (args: string[]) { | ||
const result = runScriptSync('npm', args, { | ||
return runScriptSync('npm', args, { | ||
cwd: process.cwd(), | ||
stdio: 'inherit', | ||
userAgent: undefined, | ||
}) | ||
process.exit(result.status) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import prepare, { | ||
prepareWithYamlManifest, | ||
} from '@pnpm/prepare' | ||
import exists = require('path-exists') | ||
import tape = require('tape') | ||
import promisifyTape from 'tape-promise' | ||
import { execPnpm } from './utils' | ||
|
||
const test = promisifyTape(tape) | ||
const testOnly = promisifyTape(tape.only) | ||
|
||
const CREDENTIALS = [ | ||
'--//localhost:4873/:username=username', | ||
`--//localhost:4873/:_password=${Buffer.from('password').toString('base64')}`, | ||
'--//localhost:4873/:email=foo@bar.net', | ||
] | ||
|
||
test('publish: package with package.json', async (t: tape.Test) => { | ||
prepare(t, { | ||
name: 'test-publish-package.json', | ||
version: '0.0.0', | ||
}) | ||
|
||
await execPnpm('publish', ...CREDENTIALS) | ||
}) | ||
|
||
test('publish: package with package.yaml', async (t: tape.Test) => { | ||
prepareWithYamlManifest(t, { | ||
name: 'test-publish-package.yaml', | ||
version: '0.0.0', | ||
}) | ||
|
||
await execPnpm('publish', ...CREDENTIALS) | ||
|
||
t.ok(await exists('package.yaml')) | ||
t.notOk(await exists('package.json')) | ||
}) | ||
|
||
test('publish: package with package.json5', async (t: tape.Test) => { | ||
prepareWithYamlManifest(t, { | ||
name: 'test-publish-package.json5', | ||
version: '0.0.0', | ||
}) | ||
|
||
await execPnpm('publish', ...CREDENTIALS) | ||
}) | ||
|
||
test('publish: package with package.json5 running publish from different folder', async (t: tape.Test) => { | ||
prepareWithYamlManifest(t, { | ||
name: 'test-publish-package.json5', | ||
version: '0.0.1', | ||
}) | ||
|
||
process.chdir('..') | ||
|
||
await execPnpm('publish', 'project', ...CREDENTIALS) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.