Skip to content

Commit

Permalink
fyn extra setup is no longer required (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Aug 9, 2018
1 parent 0be1eda commit f8b273b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ addons:
notifications:
email:
- XChen@walmartlabs.com
install: eval `fyn bash` && fyn --pg none install
script: eval `fyn bash` && npm test
install: fyn --pg none install
script: npm test
before_install:
- npm install -g xclap-cli fyn
29 changes: 6 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ Install these CLI tools globally: [xclap-cli] and [fyn]

```bash
$ npm install -g xclap-cli fyn
$ fyn -V
0.1.76
```

> Make sure `fyn`'s version is at least `0.1.76`
Fork and clone the repo at <https://github.com/electrode-io/electrode.git> and bootstrap all the packages.

```bash
Expand All @@ -29,31 +33,11 @@ $ npm run bootstrap

Because many of our modules depend on each other, to make local development easier, we use [fyn] to install packages when doing development.

#### Setup fyn

For [fyn]'s enhanced local dev workflow, the following two setups are needed.

```bash
$ eval `fyn bash`
$ export NODE_PRESERVE_SYMLINKS=1
```

For Windows:

```text
fyn win && fynwin
set NODE_PRESERVE_SYMLINKS 1
```

Our build scripts automatically does it, but it's a good idea to set them up anyways.

#### Try a sample

Now you can go to the `samples` folder and try the `universal-react-node` sample app, develop and test your changes over there.

```bash
$ eval `fyn bash`
$ export NODE_PRESERVE_SYMLINKS=1
$ cd samples/universal-react-node
$ fyn
$ clap dev
Expand Down Expand Up @@ -130,12 +114,11 @@ When you submit a bug report, please include the following information:
This repo has a [gitbook] documentation under `docs`. To review the docs as a gitbook locally:

- Install [gitbook-cli] and the plugins for docs.
- Note that gitbook (3.2.3) uses npm (3.9.2) to manage its own plugins and that's incompatible with [fyn]. So to serve the docs locally, you have to unset `NODE_OPTIONS`.
- That means the top level `node_modules` has to be installed using npm also.
- Note that gitbook (3.2.3) uses npm (3.9.2) to manage its own plugins and that may conflict with [fyn] installed `node_modules`.
- which is why for the top level dir of our lerna repo, we use `npm install` directly.

```bash
$ cd electrode
$ unset NODE_OPTIONS
$ npm install gitbook-cli -g
$ gitbook install
```
Expand Down
10 changes: 10 additions & 0 deletions samples/stylus-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,15 @@
},
"devDependencies": {
"electrode-archetype-react-app-dev": "../../packages/electrode-archetype-react-app-dev"
},
"fyn": {
"dependencies": {
"electrode-archetype-react-app": "../../packages/electrode-archetype-react-app",
"electrode-react-webapp": "../../packages/electrode-react-webapp",
"electrode-redux-router-engine": "../../packages/electrode-redux-router-engine"
},
"devDependencies": {
"electrode-archetype-react-app-dev": "../../packages/electrode-archetype-react-app-dev"
}
}
}
10 changes: 10 additions & 0 deletions samples/universal-react-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,15 @@
"redux-devtools": "^3.3.1",
"redux-devtools-dock-monitor": "^1.1.1",
"redux-devtools-log-monitor": "^1.0.11"
},
"fyn": {
"dependencies": {
"electrode-archetype-react-app": "../../packages/electrode-archetype-react-app",
"electrode-react-webapp": "../../packages/electrode-react-webapp",
"electrode-redux-router-engine": "../../packages/electrode-redux-router-engine"
},
"devDependencies": {
"electrode-archetype-react-app-dev": "../../packages/electrode-archetype-react-app-dev"
}
}
}
57 changes: 19 additions & 38 deletions xclap.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@ const pullLocalPackages = dir => {
const localDevPkgs = ["electrode-archetype-react-app-dev"];
const localPackagesDir = Path.relative(dir, packagesDir);

const updateToLocalPkgs = (pkgSection, pkgs) => {
if (pkgSection) {
const appPkgFile = Path.join(dir, "package.json");
const appPkgData = fs.readFileSync(appPkgFile).toString();
const appPkg = JSON.parse(appPkgData);

const updateToLocalPkgs = (section, pkgs) => {
if (appPkg[section]) {
pkgs.forEach(pkg => {
if (pkgSection[pkg]) {
pkgSection[pkg] = Path.join(localPackagesDir, pkg);
if (appPkg[section][pkg]) {
_.set(appPkg, ["fyn", section, pkg], Path.join(localPackagesDir, pkg));
}
});
}
};

const appPkgFile = Path.join(dir, "package.json");
const appPkgData = fs.readFileSync(appPkgFile).toString();
const appPkg = JSON.parse(appPkgData);
updateToLocalPkgs(appPkg["dependencies"], localPkgs);
updateToLocalPkgs(appPkg["devDependencies"], localDevPkgs);
updateToLocalPkgs("dependencies", localPkgs);
updateToLocalPkgs("devDependencies", localDevPkgs);
fs.writeFileSync(appPkgFile, `${JSON.stringify(appPkg, null, 2)}\n`);

return appPkgData;
Expand Down Expand Up @@ -94,26 +95,9 @@ const testGenerator = (testDir, name, clean, runTest, prompts) => {
});
};

let fynSetup = false;

xclap.load({
".fyn-setup": () => {
if (fynSetup) return undefined;
fynSetup = true;
return exec(true, "fyn json").then(r => {
process.env.NODE_PRESERVE_SYMLINKS = 1;
const fynEnv = JSON.parse(r.stdout);
if (fynEnv.error) {
console.log(".fyn-setup:", fynEnv.error);
} else {
process.env.NODE_OPTIONS = fynEnv.NODE_OPTIONS;
console.log("NODE_OPTIONS set to", fynEnv.NODE_OPTIONS);
}
});
},
".lerna.test": "~$lerna run test --ignore=electrode-webpack-reporter",
"test-reporter": [".fyn-setup", ".test-reporter"],
".test-reporter": {
"test-reporter": {
task: () => {
return exec(true, "lerna updated")
.then(r => {
Expand All @@ -130,17 +114,14 @@ xclap.load({
}
},
bootstrap: "~$fynpo",
test: [".fyn-setup", "bootstrap", ".lerna.test", "test-reporter", "build-test"],
"test-generator": [".fyn-setup", ".test-generator --hapi"],
"gen-hapi-app": [".fyn-setup", ".test-generator --hapi --no-test"],
"test-demo-component": [
".fyn-setup",
`~$cd samples/demo-component && fyn --pg none install && npm test`
],
"test-boilerplate": [".fyn-setup", ".test-boilerplate"],
"test-stylus-sample": [".fyn-setup", ".test-stylus-sample"],
"update-changelog": [".fyn-setup", "~$node tools/update-changelog.js"],
"gitbook-serve": [".fyn-setup", "~$gitbook serve --no-watch --no-live"],
test: ["bootstrap", ".lerna.test", "test-reporter", "build-test"],
"test-generator": [".test-generator --hapi"],
"gen-hapi-app": [".test-generator --hapi --no-test"],
"test-demo-component": [`~$cd samples/demo-component && fyn --pg none install && npm test`],
"test-boilerplate": [".test-boilerplate"],
"test-stylus-sample": [".test-stylus-sample"],
"update-changelog": ["~$node tools/update-changelog.js"],
"gitbook-serve": ["~$gitbook serve --no-watch --no-live"],
"build-test": {
desc: "Run CI test",
task: () => {
Expand Down

0 comments on commit f8b273b

Please sign in to comment.