Skip to content
Permalink
Browse files

Merge RNWCPP to Master (#2330)

* Initial commit of RNW CPP (#2065)

In this branch, we are working on a rewrite of React Native for Windows10 built in C++ that reuses the C++ core bridge implementation from Facebook’s React Native. This will allow React Native for Windows10 to innovate and provide features by sharing the same core as Facebook’s React Native.

Note - ONLY CURRENTLY BUILDABLE USING INTERNAL CREDS

We are actively working on removing all dependencies internal to Microsoft. This should be completed in the next month.

* Port recent changes to rnwcpp (#2074)

Merging on behalf of @ahimberg

* Update rnwcpp with recent changes (#2129)

* update with recent changes, resolving react-native seems to work again (#2138)

* Latest from internal repo (#2141)

* Latest from internal repo

* Update npm install script

* Make PR use standard npm registry

* typo

* Disable websocket tests for now

* Update test certs (#2145)

* Update test certs

* add publish scripts

* Turn off websocket integration tests for now

* Update publish scripts

* Update publish script

* Update publish script

* Applying package update to 0.6.4-v.0

* Update version to match RN version

* Update update-rn-version script

* Applying package update to 0.57.0-v.0

* Update evergreen script

* Update evergreen script

* Add evergreen build scripts

* Add evergreen scripts

* Update evergreen script

* Update evergeen script

* Update evergreen script to point to rnw

* Update to react-native@0.57.0-microsoft.5 (#2147)

* Folly export fixes, minor cleanups (#2146)

* add additional folly exports so .asDouble/etc work outside of react.uwp.dll
* fix include so custom viewmanager usage doesn't need reactwindowscore on include path

* Applying package update to 0.57.0-v.1

* Rename package (#2150)

* Applying package update to 0.57.0-vnext.1

* No need to use @providesModule anymore (#2156)

* Applying package update to 0.57.0-vnext.2

* Minor update to evergreen script

* Update evergreen build def

* Applying package update to 0.57.0-vnext.3

* DatePicker selected date and timezone issues (#2158)

* Update to react-native@0.57.0-microsoft.6 (#2157)

* Bump package version to published version

* Add cache to SolidColorBrushFrom() (#2160)

* add caching to SolidColorBrushFrom()

* cleanup unnecessary SolidColorBrush default constructor

* add thread_local to brush cache to support multiple UI thread (multi-windowed) application experiences

* Applying package update to 0.57.0-vnext.5

* Updating RNWCPP readme to reflect updates to status, issues tracked and some minor edits on dev tools usage in sample app instructions

* Added CODEOWNERS file for RNWCPP PRs (#2168)

* Fixes #2167

* Applying package update to 0.57.0-vnext.6

* Text component property additions: Add 'selectable', 'allowFontScaling', and 'selectionColor' properties. Enable ellipsizeMode='clip' (#2171)

* Applying package update to 0.57.0-vnext.7

* Prep for 58 merge (#2172)

* Applying package update to 0.57.0-vnext.8

* Update rnwcpp-preview with latest master (#2176)

* Updates README with repo status information (#2166)

Fixes #2049

* Updating C# Playground/Test certs to fix appveyor build (#2175)

* Applying package update to 0.57.0-vnext.9

* Fix intermittent layout problem when View contains a Content Control. Also remove IsTabStop from ScrollViewer.

* View panel measure override (#2180)


* Fix intermittent layout problem when View contains a Content Control. Also remove IsTabStop from ScrollViewer.

* Applying package update to 0.57.0-vnext.10

* View accessibility invoke (#2177)

* add Accessibility enums

* add a custom ContentControl for ViewViewManager to use with customized automation peer support

* obuild support

* cmake

* add an AccessibilityExample for role=button

* code review updates

* Applying package update to 0.57.0-vnext.11

* Remove CalendarView control should be removed from (#2186)

* Remove CalendarView

* Preparing PR

* Preparing PR

* Preparing PR

* Applying package update to 0.57.0-vnext.12

* Update to react-native@0.57.0-microsoft.7 (#2188)

* Adding simple scaffolding sample project

* Applying package update to 0.57.0-vnext.13

* Revert Playground checkin which broke our CI loop (#2193)

* Update to react-native@0.57.0-microsoft.9 (#2192)

* Applying package update to 0.57.0-vnext.14

* Text views implement padding themselves. Add ability for views to declare this so the yoga layout will not do it for them.

* fixed duplicated keys

* Applying package update to 0.57.0-vnext.15

* Update typescript to 3.3.3 (#2202)

* Basic copy of contrib docs from some of our other repos (#2189)

* Basic copy of contrub docs from some of our other repos.

* Add note to target rnwcpp-preview for the PR

* Applying package update to 0.57.0-vnext.16

* Fixup build logic (#2204)

* Applying package update to 0.57.0-vnext.17

* Remove JSCTemp dependency (#2208)

* Update to react-native@0.57.0-microsoft.11 (#2209)

* Minor code cleanup in ViewPanel.

* Applying package update to 0.57.0-vnext.18

* Applying package update to 0.57.0-vnext.19 (#2212)

* Applying package update to 0.57.0-vnext.20

* Minor code cleanup in ViewPanel. (#2211)

* Applying package update to 0.57.0-vnext.21

* Update to react-native@0.57.0-microsoft.12 (#2214)

* Stop DevSupportManager::DownloadFromAsync from blocking the UI thread (#2213)

* Fixes issue #2210

* Applying package update to 0.57.0-vnext.22

* Add create bundle task to build definition (#2215)

* Applying package update to 0.57.0-vnext.23

* Stop scaling font size. This is an artifact from an earlier time and is no longer needed.

* Stop scaling fontSize property. (#2217)

* Stop scaling font size. This is an artifact from an earlier time and is no longer needed.

* Applying package update to 0.57.0-vnext.24

* Allow V8 to not be required for VS project (#2221)

* Applying package update to 0.57.0-vnext.25

* Update just version (#2223)

* Applying package update to 0.57.0-vnext.26

* Updated projects with new $ReactNativeWindowsDir variable rather than $SolutionDir

* Updated readme

* Applying package update to 0.57.0-vnext.27

* add null check in UIManager::updateView (#2230)

* Applying package update to 0.57.0-vnext.28

* Releases file for rnwcpp versioning (#2225)

* Applying package update to 0.57.0-vnext.29

* Fix deadlock when calling detach before attach has finished (#2234)

* Applying package update to 0.57.0-vnext.30

* check isInError before calls to instanceWrapper (#2236)

* add more accessible role support on view.  add focusIn/Out events (#2229)

* add additional files to nuget package to build reactNativeHost (#2243)

* Commiting the playground app as a simple scaffolding app.

* Update to RN 58 (#2242)

* Update to RN 58

* Integration test server still pointing at old package name

* Stub out YellowBoxInspectorHeader for windesktop, as it uses NYI PixelRatio

* Disable timer tests

* Applying package update to 0.58.0-vnext.1

* Improve implementaiton of padding property for Controls.

Don't apply padding to XAML Controls when shadow node declares they don't implement padding.

ViewPanel measure code should obey Height/Width instead of DesiredSize because that's what yoga sets and this is the source of layout truth.

Set TextInput to implement Padding as it does this correctly.
Set DatePicker to measure itself as it does this properly.
Update ContentControlViewManager & SwithcViewManager to inherit ControlViewManager.

* Adding multipart FormData functionality to UWP NetworkingModule (#2246)

* Adding multipart FormData functionality to UWP NetworkingModule
* Adding headers to multipart payloads

* Applying package update to 0.58.0-vnext.2

* Fix double arrange.

* fix focus events (#2248)

* Applying package update to 0.58.0-vnext.3

* Update to react-native@0.58.6-microsoft.16 (#2250)

* Update version

* Applying package update to 0.58.0-vnext.5

* Add UWP only solution (#2252)

* Add UWP only solution

* Add ReactWindows-UWP nuget restore and MSBuild task to build definition

* Update to react-native@0.58.6-microsoft.17 (#2254)

* Applying package update to 0.58.0-vnext.6

* Reduce and rationalize some header file includes related to ShadowNodeBase & ViewManagerBase. Reduces dependencies for build. (#2251)

* Applying package update to 0.58.0-vnext.7

* Update evergreen script

* Applying package update to 0.58.0-vnext.8

* Update to react-native@0.58.6-microsoft.19 (#2257)

* Disable api-doc build step

* Enqueue outgoing messages in background thread. (#2255)

* Enqueue outgoing messages in background thread.

* Re-introduce merge-removed TimersTest skipping.

* Applying package update to 0.58.0-vnext.9

* Update evergreen script

* Applying package update to 0.58.0-vnext.10

* Fix running with bundle file in 58 - UIManager.getConstantsForViewManager (#2259)

* add missing blank line

* add UIManager.getConstantsForViewManager as expected by RN 58

* quick fix for uwp

* Update to react-native@0.58.6-microsoft.20 (#2258)

* Bump package version to unblock publish

* Applying package update to 0.58.0-vnext.12

* CLI for RNWCPP with new c# template (#2238)

* Added support for overriding properties
like ReactNativeDir, FollyDir, YogaDir via react.overrides.props in parrents dir.

* Added support for external react-native dir in metro bundler and external project.
External project should be in an ancestor directory.

* WIP: added template for cppcsharp project

* added missing deps for generator

* Changed importing nuget projects to be imported based on SolutionDir

* Added cli implementation with new template

* renemad template name from cppcsharp to vnext.
Changed default template to csharp.

* Update to react-native@0.58.6-microsoft.21 (#2265)

* Internal build def update (#2266)

* Attempt to get publish to be more robust (#2267)

* Internal build def update

* Attempt to get publish to be more robust

* Publish fixes

* More publish

* Applying package update to 0.58.0-vnext.14

* [ActivityIndicator] Map color property to Control.Foreground (#2253)

* [ActivityIndicator] Map color property to Control.Foreground

* Use TryUpdateForeground template instead

* Remove changes to ActivityIndicatorViewManager::UpdateProperties

* merge TextInput changes from 58 to uwp forked files (#2269)

* Applying package update to 0.58.0-vnext.15

* Disable RNTesterIntegrationTests.WebSocket. (#2278)

* Applying package update to 0.58.0-vnext.16

* Update to react-native@0.58.6-microsoft.22 (#2275)

* Update to react-native@0.58.6-microsoft.22

* Deal with fact that fschelpers/unicode was deleted

* More fixes

* Applying package update to 0.58.0-vnext.17

* Update ChakraCore version (#2273)

* Update ChakraCore version

* Move to version that should be publically availiable

* Missed some places

* Applying package update to 0.58.0-vnext.18

* Export UnicodeConversion.h (#2280)

* Applying package update to 0.58.0-vnext.19

* Changed url to proper repo (#2272)

* Applying package update to 0.58.0-vnext.20

* Point react-native fork dependency to github tar (#2279)

* Point react-native fork dependency to github tar

* Fix minor version number

* Update minor version, readme, and evergreen.js

* Use string interpolation...

* Add react-native to devDependencies, and add pre/post install scripts to make it a tar

* The PR task was replacing the dependencies which is done by preinstall now

* Publish logic update

* Publish logic fix

* Fix publish

* Applying package update to 0.58.0-vnext.22

* More build fixes for internal

* Applying package update to 0.58.0-vnext.23

* Remove projects needed for CLI from .npmignore

* Couple more folders needed by the projects

* Update CLI to react-native's fork URL (#2282)

* Ignore sources, dirs, and .inc files

* Re-add src to .npmignore

* Fix publish

* Applying package update to 0.58.0-vnext.24

* Split UWP and win32 builds into seperate jobs (#2285)

* Split build into more slices

* Handle cases where npm install gets interupted and leave package.json in bad state

* Use yarn and lock file.

* Ensure yarn

* Use yarn fron npm path

* Pass env arg differently

* Applying package update to 0.58.0-vnext.25

* Update README.md

* Update to react-native@0.58.6-microsoft.23 (#2288)

* Update to react-native@0.58.6-microsoft.23

* Update shrinkwrap

* Update evergreen script

* Update evergreen script

* Set filtering metadata for RNTesterIntegrationTests::WebSocket (#2286)

* Mark RNTesterIntegrationTests::WebSocket as Unstable.

* Update Azure DevOps tasks.

* Remove extra npm install step

The react-native fork dependency is being added to devDependencies through the preinstall script.

* More publish logic changes

* Applying package update to 0.58.0-vnext.26

* Sync from internal (#2290)

* Update to react-native@0.58.6-microsoft.24 (#2289)

* Update to react-native@0.58.6-microsoft.24

* Update lock file

* Applying package update to 0.58.0-vnext.27

* Update to react-native@0.58.6-microsoft.25 (#2291)

* Update to react-native@0.58.6-microsoft.25

* update lock

* Update sync scripts

* Applying package update to 0.58.0-vnext.28

* Update to react-native@0.58.6-microsoft.26 (#2292)

* Update evergreen script

* Applying package update to 0.58.0-vnext.29

* Applying package update to 0.58.0-vnext.30

* Update csproj versions

* Update npmignore and preinstall for CLI (#2295)

* Sync from internal (#2294)

* Applying package update to 0.58.0-vnext.31

* Applying package update to 0.58.0-vnext.32

* Removed unecessary projects from solution files

* Deleted WindowsSampleCSharpApp

* Deleted ReactWin32SandboxSample

* Added Playground to PR build

* Applying package update to 0.58.0-vnext.33

* Update evergreen script

* Update evergreen script

* Applying package update to 0.58.0-vnext.34

* Update evergreen script

* Update evergreen script

* Update to react-native@0.58.6-microsoft.27 (#2303)

* Fixes to uwp / windesktop js stub files (#2306)

* add missing copyright headers

* update headers, convert uwp stubs to use unimplementedview  (fixes some typos in some files llike DatePickerMacOS.uwp)

* Applying package update to 0.58.0-vnext.35

* Fix Git newline handling. (#2305)

* Applying package update to 0.58.0-vnext.36

* cli that works with published packages (#2302)

* Moved dependency projects to node_modules

* Changed cli to work with published react-native-windows package

* Added support for run-windows command

* Added getting of latest version for vnext if not specified.

* Updated yarn.lock

* Refactored get latest vnext version method

* Applying package update to 0.58.0-vnext.37

* Add vnext to rnpm-plugin-windows version (#2308)

* add vnext

* fix merge conflict

* go back to 0.2.9

* Applying package update to 0.58.0-vnext.38

* Update postinstall script to work with CLI (#2309)

* Applying package update to 0.58.0-vnext.39

* Update CLI template to match file name (#2317)

* Applying package update to 0.58.0-vnext.40

* Exclude VS 2019 from MSBuild path search (#2319)

* Applying package update to 0.58.0-vnext.41

* update assert for 0.58 compat (#2322)

* Applying package update to 0.58.0-vnext.42

* Add npm publish to public feed (#2323)

* Applying package update to 0.58.0-vnext.43

* Clean up publish tasks (#2324)

* Applying package update to 0.58.0-vnext.44

* Fix integration test setup script (#2318)

* Add newline to package.json.

* Fixed default ReactNative path for IntegrationTests script.

* Applying package update to 0.58.0-vnext.45

* Commiting updates to docs upon end of Milestone 1 (#2329)

* Applying package update to 0.58.0-vnext.46
  • Loading branch information...
kmelmon committed Apr 23, 2019
1 parent 0ee83e5 commit fe63b6415c57f3560dd333c0fad5f459d8eb6b2b
Showing 744 changed files with 133,051 additions and 12 deletions.
@@ -1,8 +1,9 @@

# Auto detect text files and perform LF normalization

* text=auto

* text=auto
*.cpp -text
*.h -text


# Force Visual Studio project files (mostly XML) to CRLF
@@ -22,3 +23,8 @@
*.vcxitems text eol=crlf
*.props text eol=crlf
*.filters text eol=crlf

*.ps1 text eol=lf
.editorconfig text eol=lf
.gitattributes text eol=lf
package.json text eol=lf
@@ -0,0 +1,179 @@
// @ts-check

// Script to keep sdx-platform up to date with GitHub/Microsoft/react-native

const path = require('path');
const request = require('request');
const execSync = require('child_process').execSync;
const fs = require('fs');
const branchNamePrefix = 'auto-update-versions';
const finalTargetBranchName = 'rnwcpp-preview';
let branchName;
let rnVersion;
let listOfChanges;

function exec(command) {
try {
console.log(`Running command: ${command}`);
return execSync(command, {
stdio: 'inherit'
});
} catch (err) {
process.exitCode = 1;
console.log(`Failure running: ${command}`);
throw err;
}
}

function sanitizeBranchName(branch) {
return branch.replace('.', '').replace('-', '');
}

let myArgs = process.argv.slice(2);
let autopr = false;
let gitHubToken = null;

while (myArgs.length) {
switch (myArgs[0]) {
case 'autopr':
autopr = true;
// This args should be the result of new Buffer(":" + <githubToken>).toString("base64")
gitHubToken = myArgs[1];
myArgs = myArgs.slice(2);
break;
default:
throw new Error('Invalid args');
}
}

// Create a new VSO PR
function createPr() {
console.log('Creating PR...');
const url = 'https://api.github.com/repos/Microsoft/react-native-windows/pulls';
request.post(
{
url: url,
json: true,
headers: {
Authorization: "Basic " + gitHubToken,
"Content-Type": 'application/json',
"User-Agent": "RNW-Evergreen Script"
},
body: {
head: branchName,
base: finalTargetBranchName,
title: `Update to react-native@${rnVersion}`,
body: `Automatic update to latest version published from @Microsoft/react-native, includes these changes:\n\`\`\`\n${listOfChanges}\n\`\`\``
}
},
function(err, httpResponse, body) {
console.log('HTTP Response \r\n -------------------------------------------------------------------------', httpResponse);
//console.log("Body Response:", body);
//console.log("err: " + err + " body.errorCode" + body.errorCode);
if (err || body.errorCode) {
throw new Error(err || body.errorCode);
}

if (!body.number) {
throw new Error('Failed to create PR.\nBody : ' + JSON.stringify(body));
}

const prId = body.number;

// Trigger automation
request.post(
{
url: `https://api.github.com/repos/Microsoft/react-native-windows/issues/${prId}/comments`,
json:true,
headers:{
Authorization: "Basic " + gitHubToken,
"Content-Type": 'application/json',
"User-Agent": "RNW-Evergreen Script"
},
body: {
body: "/azp run"
}
}
, function(err, httpResponse, body) {
console.log('HTTP Response \r\n -------------------------------------------------------------------------', httpResponse);

// Trigger AutoMerge
request.post(
{
url:`https://api.github.com/repos/Microsoft/react-native-windows/issues/${prId}/labels`,
json:true,
headers:{
Authorization: "Basic " + gitHubToken,
"Content-Type": 'application/json',
"User-Agent": "RNW-Evergreen Script"
},
body: {
labels: ["AutoMerge"]
}
},function(err, httpResponse, body) {
console.log('HTTP Response \r\n -------------------------------------------------------------------------', httpResponse);
});
});
});
}

request.get('https://raw.githubusercontent.com/Microsoft/react-native/master/package.json', function(error, response, body) {
console.log(`Get react-native's package.json request result: `);
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body);

if (error) {
console.error(`Failed to get react-native's package.json`);
throw error;
}
if (response.statusCode !== 200) {
console.error(`Failed to get react-native's package.json`);
throw new Error(`Failed to get react-native's package.json`);
}

const pkgJson = JSON.parse(body);
const pkgJsonPath = path.resolve(__dirname, '../package.json');
rnVersion = pkgJson.version;

let existingPkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));

const rnDependency = `${pkgJson.version} || https://github.com/Microsoft/react-native/archive/v${pkgJson.version}.tar.gz`;

if (existingPkgJson.peerDependencies['react-native'] === rnDependency) {
console.log(`Already at latest react-native version: ${pkgJson.version}.`);
console.log('Nothing to do...exiting');
process.exitCode = 0;
return;
}

// Collect log of changes included in this sync
// Fetch older version so that we can get the log from there to here..
try {
exec(`git remote add msrn https://github.com/Microsoft/react-native.git`);
} catch (e) {
}
exec(`git fetch msrn`);
listOfChanges = execSync(`git log --pretty=oneline --abbrev-commit v${existingPkgJson.devDependencies['react-native']}..v${pkgJson.version}`).toString();

console.log(`Updating react-native to version: ${pkgJson.version}`);
existingPkgJson.peerDependencies['react-native'] = rnDependency;
existingPkgJson.devDependencies['react-native'] = pkgJson.version;

branchName = branchNamePrefix + sanitizeBranchName(pkgJson.version);

exec(`npm install -g yarn`);

exec(`git checkout ${finalTargetBranchName}`);
exec(`git checkout -b ${branchName}`);
fs.writeFileSync(pkgJsonPath, JSON.stringify(existingPkgJson, null, 2));
// Run yarn install to update yarn.lock
exec(`${process.env.APPDATA}\\npm\\node_modules\\yarn\\bin\\yarn.cmd install`);

exec(`git add ${path.resolve(__dirname, '../yarn.lock')}`);
exec(`git add ${pkgJsonPath}`);
exec(`git commit -m "Update to react-native@${pkgJson.version}"`);
exec(`git push origin ${branchName}`);

if (autopr) createPr();
});
@@ -0,0 +1,33 @@
name: $(Date:yyyyMMdd).$(Rev:.r)

trigger: none # will disable CI builds entirely

pr: none

jobs:
- job: RNWUpdateRNVersion
displayName: React-Native-Windows Update React-Native
pool:
name: OE Standard Pool
demands: ['VisualStudio_15.0', 'OnPrem -equals False']
timeoutInMinutes: 30 # 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: false # 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@1
displayName: 'Install update script requirements'
inputs:
filename: npm
arguments: 'install request --no-save'

- task: CmdLine@2
displayName: Do Update
inputs:
script: node .ado/evergreen.js autopr $(apiAuthHeader)
workingDirectory: RNWCPP
@@ -0,0 +1,56 @@
name: $(Date:yyyyMMdd).$(Rev:.r)

trigger: none # will disable CI builds entirely

pr: none

jobs:
- job: RNWGithubPublish
displayName: React-Native-Windows GitHub Publish
pool:
name: OE Standard Pool
demands: ['VisualStudio_15.0', 'OnPrem -equals False']
timeoutInMinutes: 120 # 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: false # 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

# The Hosted 2019 pool machines look like they already have this, so it wouldn't be needed..
- task: CmdLine@2
displayName: Ensure yarn
inputs:
script: npm install -g yarn
workingDirectory: RNWCPP

- task: CmdLine@2
displayName: yarn install
inputs:
script: $(APPDATA)\npm\node_modules\yarn\bin\yarn.cmd install --frozen-lockfile
workingDirectory: RNWCPP

- task: CmdLine@2
displayName: yarn build
inputs:
script: $(APPDATA)\npm\node_modules\yarn\bin\yarn.cmd build
workingDirectory: RNWCPP

- task: CmdLine@2
displayName: Update package version
inputs:
script: node .ado/updateVersion.js
workingDirectory: RNWCPP

- task: Npm@1
displayName: npm public publish (vnext)
inputs:
command: custom
workingDir: RNWCPP
verbose: false
customCommand: 'publish --access public --tag vnext'
customEndpoint: 'React-Native-Windows NPM'
publishEndpoint: 'React-Native-Windows NPM'
@@ -0,0 +1,76 @@
// Used to update the package version

const fs = require("fs");
const path = require("path");
const execSync = require("child_process").execSync;

function exec(command) {
try {
console.log(`Running command: ${command}`);
return execSync(command, {
stdio: "inherit"
});
} catch (err) {
process.exitCode = 1;
console.log(`Failure running: ${command}`);
throw err;
}
}

function updateVersion() {
const publishBranchName = process.env.publishBranchName;
const tempPublishBranch = `publish-${Date.now()}`;

exec(`npm install -g yarn`);

// Ensure publishBranchName is same locally as remote
exec(`git fetch origin ${publishBranchName}`);
exec(`git checkout ${publishBranchName} --force`);
exec(`git reset --hard origin/${publishBranchName}`);

exec(`git checkout -b ${tempPublishBranch}`);

const pkgJsonPath = path.resolve(__dirname, "../package.json");
let pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));

let releaseVersion = pkgJson.version;

const versionGroups = /(.*-vnext\.)([0-9]*)/.exec(releaseVersion);
if (versionGroups) {
releaseVersion = versionGroups[1] + (parseInt(versionGroups[2]) + 1);
} else {
if (releaseVersion.indexOf("-") === -1) {
releaseVersion = releaseVersion + "-vnext.0";
} else {
console.log("Invalid version to publish");
exit(1);
}
}

pkgJson.version = releaseVersion;
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
console.log(`Updating package.json to version ${releaseVersion}`);

process.chdir(path.resolve(__dirname, ".."));
exec(`${process.env.APPDATA}\\npm\\node_modules\\yarn\\bin\\yarn.cmd install`);
exec(`${process.env.APPDATA}\\npm\\node_modules\\yarn\\bin\\yarn.cmd build`);

const tagName = 'vnext-' + releaseVersion;

exec(`git add ${pkgJsonPath}`);
exec(`git commit -m "Applying package update to ${releaseVersion}`);
exec(`git tag ${tagName}`);
exec(`git push origin HEAD:${tempPublishBranch} --follow-tags --verbose`);
exec(`git push origin tag ${tagName}`);

exec(`git checkout ${publishBranchName}`);
exec(`git pull origin ${publishBranchName}`);
exec(`git merge ${tempPublishBranch} --no-edit`);
exec(
`git push origin HEAD:${publishBranchName} --follow-tags --verbose`
);
exec(`git branch -d ${tempPublishBranch}`);
exec(`git push origin --delete -d ${tempPublishBranch}`);
}

updateVersion();
Oops, something went wrong.

0 comments on commit fe63b64

Please sign in to comment.
You can’t perform that action at this time.