Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
837aff7
[cli] react-native link calls into rnpm
Jun 2, 2016
0377a7a
Initial commit
grabbou Jun 2, 2016
b82c9b1
Uncomment new-library - note, this changed option to an argument
grabbou Jun 2, 2016
ee468a6
Convert to number explicitly
grabbou Jun 2, 2016
0c3429b
Add required flags
grabbou Jun 2, 2016
c495804
Use Commander.js style for errors (indent)
grabbou Jun 2, 2016
c9f9e5b
Be more explicit about the type
grabbou Jun 2, 2016
5bd9fa5
Rename params
grabbou Jun 2, 2016
acb1548
Improve error handling
grabbou Jun 2, 2016
a1c7148
Love dat explicit naming
grabbou Jun 2, 2016
a523898
Add flow here and there
grabbou Jun 2, 2016
3aa4f82
Add missing parse to flowtype
grabbou Jun 2, 2016
37259d0
Add bundle/unbundle
grabbou Jun 3, 2016
6a74c7a
Simplify binding
grabbou Jun 3, 2016
1882a02
Oops
grabbou Jun 3, 2016
b808f57
Simplify binding again
grabbou Jun 3, 2016
fe60920
Unbreak tests, @Kureev
grabbou Jun 3, 2016
103d373
Add link/unlink
grabbou Jun 3, 2016
39a73e5
Add install command
grabbou Jun 3, 2016
0b308d9
Merge local-cli config with rnpm's one
Jun 3, 2016
23bbd65
Fix flowtype errors (rnpm/ files not found)
Jun 3, 2016
5a1e4be
Remove unused config import
Jun 3, 2016
21c8fe2
Bring back rnpm plugins
grabbou Jun 3, 2016
7a4a342
Remove last item from arguments which is not argv
grabbou Jun 3, 2016
5ca41f2
Add the last one command - upgrade
grabbou Jun 3, 2016
83263f4
prune to-camel-case :fire:
grabbou Jun 3, 2016
932ff16
Add missing dep
grabbou Jun 3, 2016
7cf8414
Finally fix flow
grabbou Jun 3, 2016
06b08f6
Fix ;; and eslint fixes in rnpm
grabbou Jun 3, 2016
bc33ef3
Broken iOS test
Jun 3, 2016
e6566f5
Switch to fork temporarily
grabbou Jun 3, 2016
2842834
Fix android/isInstalled test
Jun 3, 2016
3843d21
Fix android/applyPatch test
Jun 3, 2016
78a043b
Fix makeBuildPatch test
Jun 3, 2016
4642b56
Fix android/makeSettingsPatch test
Jun 3, 2016
d17fc64
Android tests 12/12
Jun 5, 2016
53b58c4
Make Android tests to work
Jun 6, 2016
04d88d9
Cleanup legacy tests + start iOS tests migration
Jun 6, 2016
37d1754
Finish adjusting tests
Jun 6, 2016
fb7f335
Remove unused include inside removeProjectFromProject
Jun 6, 2016
2062a00
Get rid of some empty lines in the tests
Jun 6, 2016
8013c64
Fix wrong paths for register/unregister
Jun 6, 2016
edae545
Fix makeSettingsPatch spec
Jun 6, 2016
b889d09
Merge branch 'master' into feat/rnpm-cli-interface
Jul 5, 2016
7c14f21
Fix runIOS
Jul 5, 2016
ff8209f
Merge in https://github.com/rnpm/rnpm-plugin-link/pull/89
Jul 5, 2016
299746f
Support sharedLibraries config
Jul 5, 2016
9c46c91
Fix runAndroid
Jul 5, 2016
b34e32c
Merge branch 'master' into feat/rnpm-cli-interface
Jul 5, 2016
4f1a3c0
Rebase
grabbou Jul 14, 2016
f41c3d9
Add logIOS and logAndroid to rnpm-interface
grabbou Jul 16, 2016
918792c
Remove reject,resolve callsg
grabbou Jul 16, 2016
16fdd60
Merge remote-tracking branch 'upstream/master' into feat/rnpm-cli-int…
grabbou Jul 16, 2016
89e9b79
Dont show undocumented commands in help
grabbou Jul 17, 2016
9d307f8
Add example and better output
grabbou Jul 17, 2016
c73d632
Add indent
grabbou Jul 17, 2016
2cc5f62
Add warning when unrecognized command is passed
grabbou Jul 17, 2016
09376a3
Extract and make more colors
grabbou Jul 17, 2016
a76ce55
Fix unknown command
grabbou Jul 17, 2016
5e13bf0
Merge master
grabbou Jul 25, 2016
d9096fd
Bump xcode and unbreak rnpm tests
grabbou Jul 25, 2016
a710e13
Turn on core tests
grabbou Jul 25, 2016
4494eed
Fix UX
grabbou Jul 25, 2016
593b221
Fix flow issue
grabbou Jul 26, 2016
c28a7b8
Add missing mock-fs dependency for testing only
grabbou Jul 26, 2016
e2bc884
Merge branch 'master' into feat/rnpm-cli-interface
grabbou Jul 26, 2016
f58099b
Move fixtures around and fix failing jest tests
grabbou Jul 26, 2016
a6859e7
Merge branch 'feat/rnpm-cli-interface' of github.com:grabbou/react-na…
grabbou Jul 26, 2016
3f8ed0b
Export dependencies
grabbou Jul 28, 2016
907323e
bring back old file and add a note
grabbou Jul 28, 2016
6df9a56
Just use commander
grabbou Jul 28, 2016
db21afb
Merge master and resolve conflicts
grabbou Jul 28, 2016
6c24028
Merge branch 'master' into feat/rnpm-cli-interface
grabbou Jul 30, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jestSupport/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ global.regeneratorRuntime = require.requireActual('regenerator-runtime/runtime')
jest
.mock('ensureComponentIsNative')
.mock('Image')
.mock('npmlog')
.mock('NativeModules')
.mock('Text')
.mock('View');
Expand Down
101 changes: 44 additions & 57 deletions local-cli/bundle/buildBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,69 +21,56 @@ function saveBundle(output, bundle, args) {
}

function buildBundle(args, config, output = outputBundle, packagerInstance) {
return new Promise((resolve, reject) => {
// This is used by a bazillion of npm modules we don't control so we don't
// have other choice than defining it as an env variable here.
process.env.NODE_ENV = args.dev ? 'development' : 'production';

// This is used by a bazillion of npm modules we don't control so we don't
// have other choice than defining it as an env variable here.
if (!process.env.NODE_ENV) {
// If you're inlining environment variables, you can use babel to remove
// this line:
// https://www.npmjs.com/package/babel-remove-process-env-assignment
process.env.NODE_ENV = args.dev ? 'development' : 'production';
}
const options = {
projectRoots: config.getProjectRoots(),
assetRoots: config.getAssetRoots(),
blacklistRE: config.getBlacklistRE(args.platform),
getTransformOptionsModulePath: config.getTransformOptionsModulePath,
transformModulePath: args.transformer,
extraNodeModules: config.extraNodeModules,
nonPersistent: true,
resetCache: args.resetCache,
};

const transformModulePath =
args.transformer ? path.resolve(args.transformer) :
typeof config.getTransformModulePath === 'function' ? config.getTransformModulePath() :
undefined;
const requestOpts = {
entryFile: args.entryFile,
sourceMapUrl: args.sourcemapOutput,
dev: args.dev,
minify: !args.dev,
platform: args.platform,
};

const options = {
projectRoots: config.getProjectRoots(),
assetRoots: config.getAssetRoots(),
blacklistRE: config.getBlacklistRE(args.platform),
getTransformOptionsModulePath: config.getTransformOptionsModulePath,
transformModulePath: transformModulePath,
extraNodeModules: config.extraNodeModules,
nonPersistent: true,
resetCache: args['reset-cache'],
};
// If a packager instance was not provided, then just create one for this
// bundle command and close it down afterwards.
var shouldClosePackager = false;
if (!packagerInstance) {
packagerInstance = new Server(options);
shouldClosePackager = true;
}

const requestOpts = {
entryFile: args['entry-file'],
sourceMapUrl: args['sourcemap-output'],
dev: args.dev,
minify: !args.dev,
platform: args.platform,
};
const bundlePromise = output.build(packagerInstance, requestOpts)
.then(bundle => {
if (shouldClosePackager) {
packagerInstance.end();
}
return saveBundle(output, bundle, args);
});

// If a packager instance was not provided, then just create one for this
// bundle command and close it down afterwards.
var shouldClosePackager = false;
if (!packagerInstance) {
packagerInstance = new Server(options);
shouldClosePackager = true;
}
// Save the assets of the bundle
const assets = bundlePromise
.then(bundle => bundle.getAssets())
.then(outputAssets => saveAssets(
outputAssets,
args.platform,
args.assetsDest,
));

const bundlePromise = output.build(packagerInstance, requestOpts)
.then(bundle => {
if (shouldClosePackager) {
packagerInstance.end();
}
return saveBundle(output, bundle, args);
});

// Save the assets of the bundle
const assets = bundlePromise
.then(bundle => bundle.getAssets())
.then(outputAssets => saveAssets(
outputAssets,
args.platform,
args['assets-dest']
));

// When we're done saving bundle output and the assets, we're done.
resolve(assets);
});
// When we're done saving bundle output and the assets, we're done.
return assets;
}

module.exports = buildBundle;
22 changes: 13 additions & 9 deletions local-cli/bundle/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@
*/

const buildBundle = require('./buildBundle');
const bundleCommandLineArgs = require('./bundleCommandLineArgs');
const parseCommandLine = require('../util/parseCommandLine');
const outputBundle = require('./output/bundle');
const outputPrepack = require('./output/prepack');
const bundleCommandLineArgs = require('./bundleCommandLineArgs');

/**
* Builds the bundle starting to look for dependencies at the given entry path.
*/
function bundleWithOutput(argv, config, output, packagerInstance) {
const args = parseCommandLine(bundleCommandLineArgs, argv);
function bundleWithOutput(argv, config, args, output, packagerInstance) {
if (!output) {
output = args.prepack ? outputPrepack : outputBundle;
}
return buildBundle(args, config, output, packagerInstance);

}

function bundle(argv, config, packagerInstance) {
return bundleWithOutput(argv, config, undefined, packagerInstance);
function bundle(argv, config, args, packagerInstance) {
return bundleWithOutput(argv, config, args, undefined, packagerInstance);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of easier merge can you provide a shim for the old interface?
args here changed signature, our internal script expects this one:

--entry-file,/path/SomeAppBundle.js,--platform,ios,--dev,true,--bundle-output,/path/buck-out/gen/__SomeAppJS#dev_js__/main.jsbundle,--assets-dest,/path/buck-out/gen/Libraries/SomeApp#dev_res__,--sourcemap-output,/path/buck-out/gen/Libraries/SomeAppJS#dev_source_map__/source.map

Copy link
Contributor Author

@grabbou grabbou Jul 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why command line args are comma separated? Shouldn't be --entry-file /path/SomeAppBundle.js --platform ios etc? Looks like master branch doesn't handle that format either

Copy link
Contributor Author

@grabbou grabbou Jul 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When called like this:

$ node local-cli/cli.js bundle --entry-file /path/SomeAppBundle.js --platform ios --dev --bundle-output /path/buck-out/gen/__SomeAppJS#dev_js__/main.jsbundle --assets-dest /path/buck-out/gen/Libraries/SomeApp#dev_res__ --sourcemap-output /path/buck-out/gen/Libraries/SomeAppJS#dev_source_map__/source.map

the args object is:

{ 
  entryFile: '/path/SomeAppBundle.js',
  platform: 'ios',
  transformer: '/Users/grabbou/Repositories/grabbou-react-native/packager/transformer.js',
  dev: true,
  prepack: undefined,
  bridgeConfig: undefined,
  bundleOutput: '/path/buck-out/gen/__SomeAppJS#dev_js__/main.jsbundle',
  bundleEncoding: 'utf8',
  sourcemapOutput: '/path/buck-out/gen/Libraries/SomeAppJS#dev_source_map__/source.map',
  assetsDest: '/path/buck-out/gen/Libraries/SomeApp#dev_res__',
  verbose: undefined,
  resetCache: undefined
}

The names of parameters didn't change at all as far as I am aware.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is an array of keys and values mixed, the way argv does it.
They got just serialised with a comma.

On Thursday, 28 July 2016, Mike Grabowski notifications@github.com wrote:

In local-cli/bundle/bundle.js
#7899 (comment):

}

-function bundle(argv, config, packagerInstance) {

Why command line args are comma separated? Shouldn't be --entry-file
/path/SomeAppBundle.js --platform ios etc?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/pull/7899/files/a6859e7e47a8d5d4ce0802579c2df318295a5e08#r72574636,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACBdWB2WEHGVjx70-03HPq1z0RFZBi2bks5qaFg_gaJpZM4Is8X3
.

module.exports = bundle;
module.exports.withOutput = bundleWithOutput;
module.exports = {
name: 'bundle',
description: 'builds the javascript bundle for offline use',
func: bundle,
options: bundleCommandLineArgs,

// not used by the CLI itself
withOutput: bundleWithOutput,
};
47 changes: 19 additions & 28 deletions local-cli/bundle/bundleCommandLineArgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,47 @@

module.exports = [
{
command: 'entry-file',
command: '--entry-file <path>',
description: 'Path to the root JS file, either absolute or relative to JS root',
type: 'string',
required: true,
}, {
command: 'platform',
command: '--platform [string]',
description: 'Either "ios" or "android"',
type: 'string',
default: 'ios',
}, {
command: 'transformer',
description: 'Specify a custom transformer to be used',
type: 'string',
default: null,
command: '--transformer [string]',
description: 'Specify a custom transformer to be used (absolute path)',
default: require.resolve('../../packager/transformer'),
}, {
command: 'dev',
command: '--dev [boolean]',
description: 'If false, warnings are disabled and the bundle is minified',
parse: (val) => val === 'false' ? false : true,
default: true,
}, {
command: 'prepack',
description: 'If true, the output bundle will use the Prepack format.',
default: false
command: '--prepack',
description: 'When passed, the output bundle will use the Prepack format.',
}, {
command: 'bridge-config',
command: '--bridge-config [string]',
description: 'File name of a a JSON export of __fbBatchedBridgeConfig. Used by Prepack. Ex. ./bridgeconfig.json',
type: 'string'
}, {
command: 'bundle-output',
command: '--bundle-output <string>',
description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle',
type: 'string',
required: true,
}, {
command: 'bundle-encoding',
command: '--bundle-encoding [string]',
description: 'Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer).',
type: 'string',
default: 'utf8',
}, {
command: 'sourcemap-output',
command: '--sourcemap-output [string]',
description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map',
type: 'string',
}, {
command: 'assets-dest',
command: '--assets-dest [string]',
description: 'Directory name where to store assets referenced in the bundle',
type: 'string',
}, {
command: 'verbose',
command: '--verbose',
description: 'Enables logging',
default: false,
}, {
command: 'reset-cache',
command: '--reset-cache',
description: 'Removes cached files',
default: false
}
default: false,
},
];
6 changes: 3 additions & 3 deletions local-cli/bundle/output/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ function createCodeWithMap(bundle, dev) {

function saveBundleAndMap(bundle, options, log) {
const {
'bundle-output': bundleOutput,
'bundle-encoding': encoding,
bundleOutput,
bundleEncoding: encoding,
dev,
'sourcemap-output': sourcemapOutput,
sourcemapOutput
} = options;

log('start');
Expand Down
4 changes: 2 additions & 2 deletions local-cli/bundle/output/prepack.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function buildPrepackBundle(packagerClient, requestOptions) {

function savePrepackBundle(bundle, options, log) {
const {
'bundle-output': bundleOutput,
'bridge-config': bridgeConfig,
bundleOutput,
bridgeConfig,
} = options;

const result = bundle.build({
Expand Down
6 changes: 3 additions & 3 deletions local-cli/bundle/output/unbundle/as-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const MODULES_DIR = 'js-modules';
*/
function saveAsAssets(bundle, options, log) {
const {
'bundle-output': bundleOutput,
'bundle-encoding': encoding,
'sourcemap-output': sourcemapOutput,
bundleOutput,
bundleEncoding: encoding,
sourcemapOutput
} = options;

log('start');
Expand Down
6 changes: 3 additions & 3 deletions local-cli/bundle/output/unbundle/as-indexed-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const SIZEOF_UINT32 = 4;
*/
function saveAsIndexedFile(bundle, options, log) {
const {
'bundle-output': bundleOutput,
'bundle-encoding': encoding,
'sourcemap-output': sourcemapOutput,
bundleOutput,
bundleEncoding: encoding,
sourcemapOutput
} = options;

log('start');
Expand Down
12 changes: 9 additions & 3 deletions local-cli/bundle/unbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@
*/

const bundleWithOutput = require('./bundle').withOutput;
const bundleCommandLineArgs = require('./bundleCommandLineArgs');
const outputUnbundle = require('./output/unbundle');

/**
* Builds the bundle starting to look for dependencies at the given entry path.
*/
function unbundle(argv, config, packagerInstance) {
return bundleWithOutput(argv, config, outputUnbundle, packagerInstance);
function unbundle(argv, config, args, packagerInstance) {
return bundleWithOutput(argv, config, args, outputUnbundle, packagerInstance);
}

module.exports = unbundle;
module.exports = {
name: 'unbundle',
description: 'builds javascript as "unbundle" for offline use',
func: unbundle,
options: bundleCommandLineArgs,
};
Loading