Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/split-exports' into feature/redux-out-of-core
- Loading branch information
Showing
10 changed files
with
88 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,8 @@ node_modules | |
/.build | ||
/app | ||
/public | ||
|
||
# Auto-generated importable sub-modules | ||
/logger | ||
/debug | ||
/argv |
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,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.'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,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); | ||
} |
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 @@ | ||
export { default } from '../framework/common/app-argv'; |
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 @@ | ||
export { default } from '../framework/common/debug'; |
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 @@ | ||
export { default } from '../shared/logger'; |
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