Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【WIP】Automatically replace constants #15

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
```json
{
"personal": {
"web": "<CELL_FQDN>/__/front/app",
"web": "https://<CELL_FQDN>/__/front/app",
"android": "***:",
"ios": "***;"
}
Expand Down Expand Up @@ -101,6 +101,7 @@ ACLの設定は手動で行います。
1. `/__/front` の all に exec を付与します。
1. Service `/__/front` 内のスクリプト `launghSPA.js` に ServicePath `app` という名前を付けます。
![Service Configuration](docs/setting_acl/service.png)
(※本設定は`npm run deploy` 時に自動で設定するように変更になったため、必要なくなりました。)
1. `/__/public` の all に read を付与します。

#### アプリ情報の開示設定
Expand Down
33 changes: 24 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const gulp = require('gulp');
const zip = require('gulp-zip');
const replace = require('gulp-replace');
const path = require('path').posix;
const merge = require('merge-stream');
const webpack = require('webpack-stream');

const config = require('./config.js');
const PersoniumAuthClient = require('./tools/auth');
Expand All @@ -15,13 +17,23 @@ const CONSTANT = {
},
};

const constantReplacement = () =>
replace(/__CONSTANT_.*__/g, match => {
const res = config.personium.CONSTANT_DEFINITION[match];
console.log(`${match} -> ${res}`);
return res;
});

gulp.task('build_bar', () => {
return gulp
.src(['src/bar/**/*', '!src/bar/**/*.example.*'])
.pipe(zip(`${config.personium.CELL_NAME}.bar`))
.pipe(gulp.dest('dist'));
});

/**
* Prebuild Task
*/
gulp.task('copy_statics', () => {
const tasks = config.personium.DIRECTORY_MAPPING.map(mapping => {
const getDstDir = mapping => {
Expand All @@ -34,11 +46,23 @@ gulp.task('copy_statics', () => {
const dstDir = getDstDir(mapping);
return gulp
.src(mapping.filePattern, { base: mapping.srcDir })
.pipe(constantReplacement())
.pipe(gulp.dest(dstDir));
});
return merge(tasks);
});

/**
* Build Task
*/

gulp.task('webpack', () => {
return gulp
.src('./src/app/frontend/index.js')
.pipe(webpack(require('./webpack.config')))
.pipe(gulp.dest('build/public'));
});

/*
* upload Ordinal folder. (collection)
*/
Expand Down Expand Up @@ -164,12 +188,3 @@ gulp.task('deploy', () => {
);
})();
});

const webpack = require('webpack-stream');

gulp.task('webpack', () => {
return gulp
.src('src/app/frontend/index.js')
.pipe(webpack(require('./webpack.config')))
.pipe(gulp.dest('build/public'));
});
57 changes: 57 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.14.2",
"gulp": "^4.0.2",
"gulp-replace": "^1.0.0",
"gulp-zip": "^5.0.0",
"merge-stream": "^2.0.0",
"mime-types": "^2.1.24",
"prettier": "^1.18.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"regenerator-runtime": "^0.13.2",
"request": "^2.88.0",
"request-promise": "^4.2.4",
"tunnel": "0.0.6",
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
// entry: ['babel-polyfill'],
entry: ['regenerator-runtime/runtime', './src/app/frontend/index.js'],
module: {
rules: [
{
Expand Down