Skip to content
Merged
Next Next commit
Update scripts to publish react-native-macos-init
  • Loading branch information
tom-un committed Apr 4, 2020
commit 685f10363a53b6858f0841b20b75baad5e6f7b07
33 changes: 33 additions & 0 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,39 @@ jobs:
command: 'publish'
publishEndpoint: 'npmjs'

- job: RNMacOSInitNpmJSPublish
displayName: react-native-macos-init Publish to npmjs.org
pool:
vmImage: vs2017-win2016
timeoutInMinutes: 90 # how long to run the job before automatically cancelling
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
clean: true # whether to fetch clean each time
# fetchDepth: 2 # the depth of commits to ask Git to fetch
lfs: false # whether to download Git-LFS files
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch

- task: CmdLine@2
displayName: npm install
inputs:
script: |
cd packages/react-native-macos-init
npm install

- task: CmdLine@2
displayName: Bump package version
inputs:
script: node .ado/bumpFileVersions.js

- task: Npm@1
displayName: "Publish react-native-macos-init to npmjs.org"
inputs:
command: 'publish'
workingDir: 'packages/react-native-macos-init'
publishEndpoint: 'npmjs'

- job: RNGithubOfficePublish
displayName: React-Native GitHub Publish to Office
pool:
Expand Down
20 changes: 20 additions & 0 deletions .ado/versionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ function gatherVersionInfo() {
return {pkgJson, releaseVersion, branchVersionSuffix};
}

function updateReactNativeMacOSInitVersionInFile() {
const rnMacOSInitPkgJsonPath = path.resolve(__dirname, "../packages/react-native-macos-init/package.json");
const rnMacOSInitPkgJson = JSON.parse(fs.readFileSync(rnMacOSInitPkgJsonPath, "utf8"));
let rnMacOSInitReleaseVersion = rnMacOSInitPkgJson.version;
const rnMacOSInitVersionStringRegEx = new RegExp(`([0-9]*)\\.([0-9]*)\\.([0-9]*)`);
const rnMacOSInitVersionGroups = rnMacOSInitVersionStringRegEx.exec(rnMacOSInitReleaseVersion);
if (rnMacOSInitVersionGroups) {
rnMacOSInitReleaseVersion = rnMacOSInitVersionGroups[1] + '.' + rnMacOSInitVersionGroups[2] + '.' + (parseInt(rnMacOSInitVersionGroups[3]) + 1);
} else {
console.log("Invalid react-native-macos-init version to publish");
process.exit(1);
}
rnMacOSInitPkgJson.version = rnMacOSInitReleaseVersion;
fs.writeFileSync(rnMacOSInitPkgJsonPath, JSON.stringify(rnMacOSInitPkgJson, null, 2));
console.log(`Updating ${rnMacOSInitPkgJsonPath} to version ${rnMacOSInitReleaseVersion}`);
}

function updateVersionsInFiles() {

let {pkgJson, releaseVersion, branchVersionSuffix} = gatherVersionInfo();
Expand All @@ -34,6 +51,9 @@ function updateVersionsInFiles() {
pkgJson.version = releaseVersion;
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
console.log(`Updating package.json to version ${releaseVersion}`);

updateReactNativeMacOSInitVersionInFile();

return {releaseVersion, branchVersionSuffix};
}

Expand Down
82 changes: 41 additions & 41 deletions packages/react-native-macos-init/package.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"name": "react-native-macos-init",
"version": "0.0.9",
"description": "CLI to add react-native-macos to an existing react-native project",
"main": "index.js",
"repository": "https://github.com/microsoft/react-native-macos",
"license": "MIT",
"private": false,
"scripts": {
"build": "just-scripts build",
"clean": "just-scripts clean",
"lint": "just-scripts lint",
"lint:fix": "just-scripts lint:fix",
"prepublishOnly": "npm run build"
},
"bin": {
"react-native-macos-init": "./bin.js"
},
"dependencies": {
"chalk": "^3",
"npm-registry": "^0.1.13",
"prompts": "^2.3.0",
"find-up": "^4.1.0",
"semver": "^7.1.3",
"valid-url": "^1.0.9",
"yargs": "^15.1.0"
},
"devDependencies": {
"@types/chalk": "^2.2.0",
"@types/prompts": "^2.0.3",
"@types/semver": "^7.1.0",
"@types/valid-url": "^1.0.2",
"@types/yargs": "^15.0.3",
"just-scripts": "^0.36.1",
"typescript": "3.5.3"
},
"files": [
"bin.js",
"lib-commonjs",
"README.md"
]
}
"name": "react-native-macos-init",
"version": "0.0.0",
"description": "CLI to add react-native-macos to an existing react-native project",
"main": "index.js",
"repository": "https://github.com/microsoft/react-native-macos",
"license": "MIT",
"private": false,
"scripts": {
"build": "just-scripts build",
"clean": "just-scripts clean",
"lint": "just-scripts lint",
"lint:fix": "just-scripts lint:fix",
"prepublishOnly": "npm run build"
},
"bin": {
"react-native-macos-init": "./bin.js"
},
"dependencies": {
"chalk": "^3",
"npm-registry": "^0.1.13",
"prompts": "^2.3.0",
"find-up": "^4.1.0",
"semver": "^7.1.3",
"valid-url": "^1.0.9",
"yargs": "^15.1.0"
},
"devDependencies": {
"@types/chalk": "^2.2.0",
"@types/prompts": "^2.0.3",
"@types/semver": "^7.1.0",
"@types/valid-url": "^1.0.2",
"@types/yargs": "^15.0.3",
"just-scripts": "^0.36.1",
"typescript": "3.5.3"
},
"files": [
"bin.js",
"lib-commonjs",
"README.md"
]
}