-
Notifications
You must be signed in to change notification settings - Fork 24k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This gives Frameworks more control in selecting specific tasks and integrating the return types data in their UI. For example piping `stdout` to the user or using packages like [Listr2](https://www.npmjs.com/package/listr2) to run tasks in parallel and show progress. The ordering is suggestive (but also enforced by some assertions). Frameworks are free to do what they want. The order was implicit in the previous data structure with lists of Tasks, but made it difficult to tap into each async task. I've also had to rework how we transpile the code if directly executed from the monorepo. This keeps our: - flow types valid, - allows the core-cli-utils package to be built (to generate TypeScript types and a valid npm module), and - allows direct transpiled execution as a yarn script. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D56242487
- Loading branch information
1 parent
bb2c13a
commit 6122859
Showing
26 changed files
with
316 additions
and
173 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
// Should only used when called in the monorepo when we don't want to use the `yarn run build` | ||
// step to transpile to project. When used as a vanilla npm package, it should be built and | ||
// exported with `dist/index.flow.js` as main. | ||
// | ||
// The reason for this workaround is that flow-api-translator can't understand ESM and CJS style | ||
// exports in the same file. Throw in a bit of Flow in the mix and it all goes to hell. | ||
// | ||
// See packages/helloworld/cli.js for an example of how to swap this out in the monorepo. | ||
if (process.env.BUILD_EXCLUDE_BABEL_REGISTER == null) { | ||
require('../../../scripts/build/babel-register').registerForMonorepo(); | ||
} | ||
|
||
module.exports = require('./index.flow.js'); |
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
// TODO(T187224491): js1 jest doesn't install the correct commander, instead | ||
// using the one in xplat/js/node_modules/commander which is much older. | ||
// Either roll back to that version or upgrade. | ||
import cli from '../cli.flow.js'; | ||
import fs from 'fs'; | ||
|
||
describe('cli.js', () => { | ||
let pkgJson = { | ||
name: 'helloworld-mock', | ||
dependencies: { | ||
'react-native': '0.0.0', | ||
}, | ||
devDependencies: { | ||
listr: '^1.2.3', | ||
'some-dev-dep': '1.0.0', | ||
}, | ||
}; | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
describe('set-version', () => { | ||
it('without arguments this should not modify the package.json', () => { | ||
const snapshot = JSON.stringify(pkgJson, null, 2); | ||
jest.spyOn(fs, 'readFileSync').mockReturnValue(snapshot); | ||
const spy = jest.spyOn(fs, 'writeFileSync'); | ||
|
||
cli.parse(['set-version'], {from: 'user'}); | ||
|
||
expect(spy.mock.lastCall[1]).toEqual(snapshot); | ||
}); | ||
|
||
it('modified and adds dependencies', () => { | ||
const snapshot = JSON.stringify(pkgJson, null, 2); | ||
jest.spyOn(fs, 'readFileSync').mockReturnValue(snapshot); | ||
const spy = jest.spyOn(fs, 'writeFileSync'); | ||
|
||
cli.parse( | ||
[ | ||
'set-version', | ||
'react-native@^0.1.1', | ||
'foobar@file:/woot/berry', | ||
'some-dev-dep@*', | ||
], | ||
{from: 'user'}, | ||
); | ||
const updated = JSON.parse(spy.mock.lastCall[1]); | ||
expect(updated).toMatchObject({ | ||
dependencies: { | ||
'react-native': '^0.1.1', | ||
foobar: 'file:/woot/berry', | ||
}, | ||
devDependencies: { | ||
'some-dev-dep': '*', | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,42 +1,13 @@ | ||
# Project-wide Gradle settings. | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
|
||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
|
||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m | ||
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
|
||
# AndroidX package structure to make it clearer which packages are bundled with the | ||
# Android operating system, and which are packaged with your app's APK | ||
# https://developer.android.com/topic/libraries/support-library/androidx-rn | ||
org.gradle.parallel=true | ||
android.useAndroidX=true | ||
# Automatically convert third-party libraries to use AndroidX | ||
android.enableJetifier=true | ||
|
||
# Use this property to specify which architecture you want to build. | ||
# You can also override it from the CLI using | ||
# ./gradlew <task> -PreactNativeArchitectures=x86_64 | ||
# TODO: Do we want to limit the architectures we test on? | ||
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 | ||
|
||
# Use this property to enable support to the new architecture. | ||
# This will allow you to use TurboModules and the Fabric render in | ||
# your application. You should enable this flag either if you want | ||
# to write custom TurboModules/Fabric components OR use libraries that | ||
# are providing them. | ||
reactNativeArchitectures=arm64-v8a | ||
newArchEnabled=true | ||
|
||
# Use this property to enable or disable the Hermes JS engine. | ||
# If set to false, you will be using JSC instead. | ||
hermesEnabled=true |
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.
Oops, something went wrong.