Skip to content

Commit

Permalink
Merge branch 'feature/split-exports' into feature/redux-out-of-core
Browse files Browse the repository at this point in the history
  • Loading branch information
ephys committed Sep 24, 2018
2 parents d6c2eb0 + 05d241b commit 0dd2126
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -11,3 +11,8 @@ node_modules
/.build
/app
/public

# Auto-generated importable sub-modules
/logger
/debug
/argv
10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="0.14.1"></a>
## [0.14.1](https://github.com/foobarhq/reworkjs/compare/v0.14.0...v0.14.1) (2018-08-09)


### Bug Fixes

* make get-translations node mock work on non-unix filesystems ([a4424b3](https://github.com/foobarhq/reworkjs/commit/a4424b3))



<a name="0.14.0"></a>
# [0.14.0](https://github.com/foobarhq/reworkjs/compare/v0.13.0...v0.14.0) (2018-06-12)

Expand Down
4 changes: 2 additions & 2 deletions index.js
@@ -1,2 +1,2 @@
export { default as logger } from './es/shared/logger';
export { default as debug } from './es/framework/common/debug';
// TODO: list available submodules.
throw new Error('Do not import @reworkjs/reworkjs directly. Import one of its submodules.');
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@reworkjs/reworkjs",
"version": "0.14.0",
"version": "0.14.1",
"description": "A react framework that works out of the box",
"repository": {
"type": "git",
Expand All @@ -17,7 +17,7 @@
"lint": "npm run lint:eslint && flow",
"lint:eslint": "eslint src --report-unused-disable-directives",
"lint:staged": "lint-staged",
"build": "gulp build",
"build": "gulp build && ./scripts/generate-public-submodules.js",
"build:watch": "gulp build:watch",
"precommit": "npm run lint:staged",
"prepublishOnly": "npm run build",
Expand Down
62 changes: 62 additions & 0 deletions scripts/generate-public-submodules.js
@@ -0,0 +1,62 @@
#!/usr/bin/env node

// eslint-disable-next-line
const fs = require('fs');

// eslint-disable-next-line
const path = require('path');

const PROJECT_ROOT = path.resolve(`${__dirname}/..`);
const GITIGNORE_FILE = `${PROJECT_ROOT}/.gitignore`;

const exportables = fs.readdirSync(`${PROJECT_ROOT}/src/exportables`);
let gitignore = fs.readFileSync(GITIGNORE_FILE).toString();

for (const exportable of exportables) {
const moduleName = path.parse(exportable).name;

addToGitIgnore(moduleName);

if (fs.existsSync(`${PROJECT_ROOT}/${moduleName}/package.json`)) {
continue;
}

fs.mkdirSync(`${PROJECT_ROOT}/${moduleName}`);
fs.writeFileSync(`${PROJECT_ROOT}/${moduleName}/package.json`, generatePackageJson(exportable));
}

fs.writeFileSync(GITIGNORE_FILE, gitignore);

function generatePackageJson(exportable) {
return JSON.stringify({
private: true,
main: `../lib/exportables/${exportable}`,
module: `../es/exportables/${exportable}`,
'es:next': `../es/exportables/${exportable}`,
});
}

function addToGitIgnore(moduleName) {

const ignoreDirective = `/${moduleName}`;

if (gitignore.includes(ignoreDirective)) {
return;
}

const HEADING = '# Auto-generated importable sub-modules\n';

let index = gitignore.indexOf(HEADING);
if (index === -1) {
index = gitignore.length + 1;
gitignore += `\n${HEADING}`;
}

index += HEADING.length;

gitignore = insertString(gitignore, `${ignoreDirective}\n`, index);
}

function insertString(strA, strB, position) {
return strA.slice(0, position) + strB + strA.slice(position);
}
1 change: 1 addition & 0 deletions src/exportables/argv.js
@@ -0,0 +1 @@
export { default } from '../framework/common/app-argv';
1 change: 1 addition & 0 deletions src/exportables/debug.js
@@ -0,0 +1 @@
export { default } from '../framework/common/debug';
1 change: 1 addition & 0 deletions src/exportables/logger.js
@@ -0,0 +1 @@
export { default } from '../shared/logger';
5 changes: 3 additions & 2 deletions src/shared/get-translations/index.js
Expand Up @@ -20,8 +20,9 @@ type BundleLoader = (file: string) => BundleModuleLoader;
function requireContext(path: string, recursive: boolean, filter: RegExp): BundleLoader {
const files = recursiveReadSync(path)
.filter(file => filter.test(file))
// replace absolute path with relative path to webpack behavior
.map(file => `.${file.substr(path.length)}`);
// replace absolute path with relative path to match webpack behavior
// and replace windows \ path delimiter with UNIX & web style
.map(file => `.${file.substr(path.length)}`.replace(/\\/g, '/'));

// mock bundle-loader:
const bundle = function getLoader(fileName: string) {
Expand Down

0 comments on commit 0dd2126

Please sign in to comment.