diff --git a/.ado/publish.yml b/.ado/publish.yml index 1652c570c030be..779f0e2162ab82 100644 --- a/.ado/publish.yml +++ b/.ado/publish.yml @@ -139,3 +139,14 @@ jobs: inputs: PathtoPublish: '$(Build.StagingDirectory)\final' ArtifactName: 'ReactNative-Final' + + - task: CmdLine@2 + displayName: "Prepare package.json for npm publishing as react-native-macos" + inputs: + script: node .ado/renamePackageToMac.js + + - task: Npm@1 + displayName: "Publish react-native-macos to npmjs.org" + inputs: + command: 'publish' + publishEndpoint: 'npmjs' diff --git a/.ado/renamePackageToMac.js b/.ado/renamePackageToMac.js new file mode 100644 index 00000000000000..32dfed2627d2a2 --- /dev/null +++ b/.ado/renamePackageToMac.js @@ -0,0 +1,3 @@ +// @ts-check +const {updatePackageName} = require('./versionUtils'); +updatePackageName('react-native-macos'); \ No newline at end of file diff --git a/.ado/versionUtils.js b/.ado/versionUtils.js index 9a74e62b02bc99..cda5beaa13023a 100644 --- a/.ado/versionUtils.js +++ b/.ado/versionUtils.js @@ -37,9 +37,17 @@ function updateVersionsInFiles() { return {releaseVersion, branchVersionSuffix}; } +function updatePackageName(name) { + let pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8")); + pkgJson.name = name; + fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2)); + console.log(`Updating package.json to name ${name}`); +} + module.exports = { gatherVersionInfo, publishBranchName, pkgJsonPath, - updateVersionsInFiles + updateVersionsInFiles, + updatePackageName } \ No newline at end of file