This repository has been archived by the owner on Dec 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move CLI package, rewrite starter project to new runtime
Reviewed By: MartinSherburn Differential Revision: D7734468 fbshipit-source-id: 0b31d76792b9def172cea8a3cd24a4dcaff7bba3
- Loading branch information
1 parent
781bd17
commit db27f90
Showing
29 changed files
with
152 additions
and
127 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
File renamed without changes.
20 changes: 10 additions & 10 deletions
20
react-vr-cli/README.md → packages/react-360-cli/README.md
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,34 +1,34 @@ | ||
# React VR CLI | ||
# React 360 CLI | ||
|
||
React VR is distributed as two packages, `react-vr` and `react-vr-cli`. The | ||
first one contains all of the code necessary to build React VR applications, | ||
React 360 is distributed as two packages, `react-360` and `react-360-cli`. The | ||
first one contains all of the code necessary to build interactive 360 applications, | ||
and is installed as part of your project's dependencies. This directory contains | ||
the code for the second one: a command-line tool that should be installed | ||
globally (`npm install -g react-vr-cli`) and which allows you to quickly | ||
initialize React VR projects. | ||
globally (`npm install -g react-360-cli`) and which allows you to quickly | ||
initialize React 360 projects. | ||
|
||
## Using the CLI | ||
|
||
Once the CLI has been globally installed, you can use it to generate new | ||
projects. Running the command: | ||
|
||
``` | ||
react-vr init MyProject | ||
react-360 init MyProject | ||
``` | ||
|
||
will create a new project directory called `MyProject`. It will create all of | ||
the files necessary to get started with React VR, and will automatically run | ||
the files necessary to get started with React 360, and will automatically run | ||
`npm install` to fetch your project's dependencies. | ||
|
||
Once a project has been generated, you can run `npm start` to launch the | ||
packager and begin running your application. | ||
|
||
## Generators | ||
|
||
The React VR CLI creates the starter project based upon the files found in the | ||
The React 360 CLI creates the starter project based upon the files found in the | ||
`generators` directory. These are very simple JavaScript modules that produce | ||
files from string templates. Configuration variables can be passed from the CLI | ||
to these generators, which return an object containing two keys: `filename` and | ||
`content`. Together, these are used to create a file at the generator's relative | ||
location. For example, a generator located in `generators/vr` will produce a | ||
file in `$PROJECT_DIRECTORY/vr/`. | ||
location. For example, a generator located in `generators/subdir` will produce a | ||
file in `$PROJECT_DIRECTORY/subdir/`. |
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 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,36 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
module.exports = config => ({ | ||
filename: 'client.js', | ||
contents: `// This file contains the boilerplate to execute your React app. | ||
// If you want to modify your application's content, start in "index.js" | ||
import {ReactInstance} from 'react-360-web'; | ||
function init(bundle, parent, options = {}) { | ||
const r360 = new ReactInstance(bundle, parent, { | ||
// Add custom options here | ||
fullScreen: true, | ||
...options, | ||
}); | ||
// Render your app content to the default cylinder surface | ||
r360.renderToSurface( | ||
r360.createRoot('${config.name}', { /* initial props */ }), | ||
r360.getDefaultSurface() | ||
); | ||
// Load the initial environment | ||
r360.compositor.setBackground(r360.getAssetURL('360_world.jpg')); | ||
} | ||
window.React360 = {init}; | ||
`, | ||
}); |
File renamed without changes.
File renamed without changes.
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,56 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
module.exports = config => ({ | ||
filename: 'index.js', | ||
contents: `import React from 'react'; | ||
import { | ||
AppRegistry, | ||
StyleSheet, | ||
Text, | ||
View, | ||
} from 'react-360'; | ||
export default class ${config.name} extends React.Component { | ||
render() { | ||
return ( | ||
<View style={styles.panel}> | ||
<View style={styles.greetingBox}> | ||
<Text style={styles.greeting}> | ||
Welcome to React 360 | ||
</Text> | ||
</View> | ||
</View> | ||
); | ||
} | ||
}; | ||
const styles = StyleSheet.create({ | ||
panel: { | ||
// Fill the entire surface | ||
width: 1000, | ||
height: 600, | ||
backgroundColor: 'rgba(255, 255, 255, 0.4)', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
greetingBox: { | ||
padding: 20, | ||
backgroundColor: '#000000', | ||
borderColor: '#639dda', | ||
borderWidth: 2, | ||
}, | ||
greeting: { | ||
fontSize: 30, | ||
}, | ||
}); | ||
AppRegistry.registerComponent('${config.name}', () => ${config.name}); | ||
`, | ||
}); |
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
14 changes: 14 additions & 0 deletions
14
packages/react-360-cli/generators/watchmanconfig.generator.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
module.exports = config => ({ | ||
filename: '.watchmanconfig', | ||
contents: `{} | ||
`, | ||
}); |
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.