webiny 0.8.33 → 6.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -15
- package/admin/aco.d.ts +2 -0
- package/admin/aco.js +4 -0
- package/admin/aco.js.map +1 -0
- package/admin/buildParams.d.ts +1 -0
- package/admin/buildParams.js +3 -0
- package/admin/buildParams.js.map +1 -0
- package/admin/cms/entry/editor.d.ts +11 -0
- package/admin/cms/entry/editor.js +13 -0
- package/admin/cms/entry/editor.js.map +1 -0
- package/admin/cms/entry/list.d.ts +2 -0
- package/admin/cms/entry/list.js +4 -0
- package/admin/cms/entry/list.js.map +1 -0
- package/admin/cms/fieldRenderers/dynamicZone.d.ts +7 -0
- package/admin/cms/fieldRenderers/dynamicZone.js +9 -0
- package/admin/cms/fieldRenderers/dynamicZone.js.map +1 -0
- package/admin/cms/fieldRenderers/object.d.ts +1 -0
- package/admin/cms/fieldRenderers/object.js +3 -0
- package/admin/cms/fieldRenderers/object.js.map +1 -0
- package/admin/cms/lexical.d.ts +16 -0
- package/admin/cms/lexical.js +17 -0
- package/admin/cms/lexical.js.map +1 -0
- package/admin/cms.d.ts +8 -0
- package/admin/cms.js +9 -0
- package/admin/cms.js.map +1 -0
- package/admin/configs.d.ts +1 -0
- package/admin/configs.js +3 -0
- package/admin/configs.js.map +1 -0
- package/admin/envConfig.d.ts +1 -0
- package/admin/envConfig.js +3 -0
- package/admin/envConfig.js.map +1 -0
- package/admin/form.d.ts +11 -0
- package/admin/form.js +12 -0
- package/admin/form.js.map +1 -0
- package/admin/graphqlClient.d.ts +1 -0
- package/admin/graphqlClient.js +3 -0
- package/admin/graphqlClient.js.map +1 -0
- package/admin/lexical.d.ts +15 -0
- package/admin/lexical.js +16 -0
- package/admin/lexical.js.map +1 -0
- package/admin/localStorage.d.ts +2 -0
- package/admin/localStorage.js +4 -0
- package/admin/localStorage.js.map +1 -0
- package/admin/router.d.ts +4 -0
- package/admin/router.js +6 -0
- package/admin/router.js.map +1 -0
- package/admin/security.d.ts +9 -0
- package/admin/security.js +11 -0
- package/admin/security.js.map +1 -0
- package/admin/tenancy.d.ts +2 -0
- package/admin/tenancy.js +4 -0
- package/admin/tenancy.js.map +1 -0
- package/admin/ui.d.ts +62 -0
- package/admin/ui.js +64 -0
- package/admin/ui.js.map +1 -0
- package/admin/website-builder/lexical.d.ts +17 -0
- package/admin/website-builder/lexical.js +18 -0
- package/admin/website-builder/lexical.js.map +1 -0
- package/admin/website-builder/page/editor.d.ts +2 -0
- package/admin/website-builder/page/editor.js +4 -0
- package/admin/website-builder/page/editor.js.map +1 -0
- package/admin/website-builder/page/list.d.ts +1 -0
- package/admin/website-builder/page/list.js +3 -0
- package/admin/website-builder/page/list.js.map +1 -0
- package/admin/website-builder/redirect/list.d.ts +1 -0
- package/admin/website-builder/redirect/list.js +3 -0
- package/admin/website-builder/redirect/list.js.map +1 -0
- package/admin/website-builder.d.ts +2 -0
- package/admin/website-builder.js +4 -0
- package/admin/website-builder.js.map +1 -0
- package/admin.d.ts +13 -0
- package/admin.js +15 -0
- package/admin.js.map +1 -0
- package/ambient/images.d.ts +22 -0
- package/api/buildParams.d.ts +1 -0
- package/api/buildParams.js +3 -0
- package/api/buildParams.js.map +1 -0
- package/api/cms/entry.d.ts +40 -0
- package/api/cms/entry.js +41 -0
- package/api/cms/entry.js.map +1 -0
- package/api/cms/group.d.ts +10 -0
- package/api/cms/group.js +11 -0
- package/api/cms/group.js.map +1 -0
- package/api/cms/model.d.ts +18 -0
- package/api/cms/model.js +17 -0
- package/api/cms/model.js.map +1 -0
- package/api/eventPublisher.d.ts +1 -0
- package/api/eventPublisher.js +3 -0
- package/api/eventPublisher.js.map +1 -0
- package/api/graphql.d.ts +3 -0
- package/api/graphql.js +5 -0
- package/api/graphql.js.map +1 -0
- package/api/keyValueStore.d.ts +1 -0
- package/api/keyValueStore.js +3 -0
- package/api/keyValueStore.js.map +1 -0
- package/api/logger.d.ts +1 -0
- package/api/logger.js +3 -0
- package/api/logger.js.map +1 -0
- package/api/security/apiKey.d.ts +7 -0
- package/api/security/apiKey.js +9 -0
- package/api/security/apiKey.js.map +1 -0
- package/api/security/authentication.d.ts +1 -0
- package/api/security/authentication.js +3 -0
- package/api/security/authentication.js.map +1 -0
- package/api/security/role.d.ts +5 -0
- package/api/security/role.js +7 -0
- package/api/security/role.js.map +1 -0
- package/api/security/user.d.ts +6 -0
- package/api/security/user.js +8 -0
- package/api/security/user.js.map +1 -0
- package/api/security.d.ts +6 -0
- package/api/security.js +8 -0
- package/api/security.js.map +1 -0
- package/api/system.d.ts +1 -0
- package/api/system.js +3 -0
- package/api/system.js.map +1 -0
- package/api/tasks.d.ts +2 -0
- package/api/tasks.js +4 -0
- package/api/tasks.js.map +1 -0
- package/api/tenancy.d.ts +6 -0
- package/api/tenancy.js +8 -0
- package/api/tenancy.js.map +1 -0
- package/api/tenant-manager.d.ts +2 -0
- package/api/tenant-manager.js +3 -0
- package/api/tenant-manager.js.map +1 -0
- package/api/website-builder/nextjs.d.ts +1 -0
- package/api/website-builder/nextjs.js +3 -0
- package/api/website-builder/nextjs.js.map +1 -0
- package/api/website-builder/page.d.ts +12 -0
- package/api/website-builder/page.js +14 -0
- package/api/website-builder/page.js.map +1 -0
- package/api/website-builder/redirect.d.ts +8 -0
- package/api/website-builder/redirect.js +10 -0
- package/api/website-builder/redirect.js.map +1 -0
- package/api.d.ts +1 -0
- package/api.js +3 -0
- package/api.js.map +1 -0
- package/cli/command.d.ts +1 -0
- package/cli/command.js +3 -0
- package/cli/command.js.map +1 -0
- package/cli/index.d.ts +2 -0
- package/cli/index.js +4 -0
- package/cli/index.js.map +1 -0
- package/configs/tsconfig.json +52 -0
- package/extensions.d.ts +8 -0
- package/extensions.js +10 -0
- package/extensions.js.map +1 -0
- package/global.d.ts +8 -0
- package/global.js +14 -0
- package/global.js.map +1 -0
- package/infra/admin.d.ts +7 -0
- package/infra/admin.js +9 -0
- package/infra/admin.js.map +1 -0
- package/infra/api.d.ts +7 -0
- package/infra/api.js +9 -0
- package/infra/api.js.map +1 -0
- package/infra/core.d.ts +6 -0
- package/infra/core.js +8 -0
- package/infra/core.js.map +1 -0
- package/infra/index.d.ts +8 -0
- package/infra/index.js +10 -0
- package/infra/index.js.map +1 -0
- package/package.json +108 -33
- package/.gitattributes +0 -39
- package/.npmignore +0 -163
- package/bin/webiny.js +0 -7
- package/index.js +0 -94
- package/lib/app.js +0 -27
- package/lib/boot/checkRequirements.js +0 -144
- package/lib/boot/checkUpdates.js +0 -55
- package/lib/boot/setup.js +0 -26
- package/lib/menu.js +0 -31
- package/lib/navigation.js +0 -134
- package/lib/plugin.js +0 -32
- package/lib/webiny.js +0 -330
- package/postinstall.js +0 -26
package/lib/navigation.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
const inquirer = require('inquirer');
|
|
2
|
-
const chalk = require('chalk');
|
|
3
|
-
const _ = require('lodash');
|
|
4
|
-
const Webiny = require('./webiny');
|
|
5
|
-
|
|
6
|
-
class Menu {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.plugins = Webiny.getPlugins();
|
|
9
|
-
this.webinyConfig = Webiny.getConfig();
|
|
10
|
-
this.lastRun = this.webinyConfig.lastRun;
|
|
11
|
-
this.apps = Webiny.getApps();
|
|
12
|
-
this.appChoices = [
|
|
13
|
-
{name: 'All', value: 'all'}
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
if (_.get(this.lastRun, 'apps.length', 0) > 0) {
|
|
17
|
-
this.appChoices.push({
|
|
18
|
-
name: 'Last selection: ' + chalk.cyan(this.lastRun.apps.join(', ')),
|
|
19
|
-
value: 'last'
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
this.appChoices.push(new inquirer.Separator());
|
|
24
|
-
this.apps.map(app => {
|
|
25
|
-
this.appChoices.push({
|
|
26
|
-
name: app.getName(),
|
|
27
|
-
value: app
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
normalizeApps(answers, config) {
|
|
33
|
-
if (_.has(answers, 'apps')) {
|
|
34
|
-
config.apps = [];
|
|
35
|
-
|
|
36
|
-
// If more than 1 option is selected - remove 'all' from the selected options
|
|
37
|
-
if (answers.apps.length > 1) {
|
|
38
|
-
_.remove(answers.apps, function (a) {
|
|
39
|
-
return a === 'all';
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (answers.apps[0] === 'all') {
|
|
44
|
-
config.apps = this.apps;
|
|
45
|
-
} else {
|
|
46
|
-
// Combine 'Last selection' (if selected) with other selected apps
|
|
47
|
-
_.map(answers.apps, a => {
|
|
48
|
-
if (a === 'last') {
|
|
49
|
-
// Select last selected apps but skip those not present in the project
|
|
50
|
-
_.merge(config.apps, _.map(this.lastRun.apps, appName => {
|
|
51
|
-
const found = _.find(this.apps, app => app.getName() === appName);
|
|
52
|
-
if (found) {
|
|
53
|
-
config.apps.push(found);
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
} else {
|
|
57
|
-
config.apps.push(a);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return config.apps;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
render() {
|
|
67
|
-
const choices = [];
|
|
68
|
-
|
|
69
|
-
_.each(this.plugins, (plugin, name) => {
|
|
70
|
-
const menu = plugin.getMenu();
|
|
71
|
-
if (menu) {
|
|
72
|
-
if (menu.getLineBefore()) {
|
|
73
|
-
choices.push(new inquirer.Separator());
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
choices.push({name: menu.getTitle(), value: name});
|
|
77
|
-
|
|
78
|
-
if (menu.getLineAfter()) {
|
|
79
|
-
choices.push(new inquirer.Separator());
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Output a blank line
|
|
85
|
-
Webiny.log('');
|
|
86
|
-
inquirer.prompt([{
|
|
87
|
-
type: 'list',
|
|
88
|
-
name: 'task',
|
|
89
|
-
message: 'What would you like to do?',
|
|
90
|
-
choices,
|
|
91
|
-
filter: function (val) {
|
|
92
|
-
return val.toLowerCase();
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
95
|
-
type: 'checkbox',
|
|
96
|
-
name: 'apps',
|
|
97
|
-
message: 'Select apps',
|
|
98
|
-
choices: this.appChoices,
|
|
99
|
-
default: ['all'],
|
|
100
|
-
when: answers => {
|
|
101
|
-
const plugin = _.find(this.plugins, (pl, name) => name === answers.task);
|
|
102
|
-
if (!plugin) {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
return plugin.getSelectApps();
|
|
106
|
-
},
|
|
107
|
-
validate: answer => {
|
|
108
|
-
if (answer.length < 1) {
|
|
109
|
-
return 'You must choose at least one option';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
}]).then(answers => {
|
|
115
|
-
const task = answers.task;
|
|
116
|
-
const config = {};
|
|
117
|
-
config.apps = this.normalizeApps(answers, config);
|
|
118
|
-
|
|
119
|
-
this.lastRun.apps = _.map(config.apps, app => app.getName());
|
|
120
|
-
Webiny.saveConfig(_.assign(this.webinyConfig, {lastRun: this.lastRun}));
|
|
121
|
-
|
|
122
|
-
return this.runTask(task, config);
|
|
123
|
-
}).catch(err => {
|
|
124
|
-
Webiny.failure(err.message, err.stack);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
runTask(task, config) {
|
|
129
|
-
return this.plugins[task].runWizard(config, () => this.render(), (task, config) => this.runTask(task, config));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
module.exports = Menu;
|
package/lib/plugin.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
class Plugin {
|
|
2
|
-
constructor(program) {
|
|
3
|
-
this.selectApps = true;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
getMenu() {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
getSelectApps() {
|
|
11
|
-
return this.selectApps;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
runTask(config, onFinish) {
|
|
15
|
-
// Override to implement
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
runWizard(config, onFinish) {
|
|
19
|
-
return this.runTask(config, onFinish);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
processHook(hook, params) {
|
|
23
|
-
const Webiny = require('webiny/lib/webiny');
|
|
24
|
-
let chain = Promise.resolve(params);
|
|
25
|
-
Webiny.getHooks(hook).map(script => {
|
|
26
|
-
chain = chain.then(() => Promise.resolve(require(script)(params)));
|
|
27
|
-
});
|
|
28
|
-
return chain;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = Plugin;
|
package/lib/webiny.js
DELETED
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
const fs = require('fs-extra');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const _ = require('lodash');
|
|
6
|
-
const yaml = require('js-yaml');
|
|
7
|
-
const program = require('commander');
|
|
8
|
-
const execSync = require('child_process').execSync;
|
|
9
|
-
const App = require('./app');
|
|
10
|
-
|
|
11
|
-
const folders = {};
|
|
12
|
-
|
|
13
|
-
function getFolders(dir, force) {
|
|
14
|
-
if (!force && folders[dir]) {
|
|
15
|
-
return folders[dir];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
folders[dir] = fs.readdirSync(dir).filter(file => {
|
|
20
|
-
return fs.statSync(path.join(dir, file)).isDirectory() && file !== '.git';
|
|
21
|
-
});
|
|
22
|
-
return folders[dir];
|
|
23
|
-
} catch (e) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function readJsApps(app, dir, Webiny) {
|
|
29
|
-
const jsApps = [];
|
|
30
|
-
getFolders(dir).map(jsApp => {
|
|
31
|
-
jsApps.push(
|
|
32
|
-
new App(app, jsApp, _.trimStart(dir.replace(Webiny.projectRoot(), '') + '/' + jsApp, '/'))
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return jsApps;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
class Webiny {
|
|
41
|
-
constructor() {
|
|
42
|
-
this.plugins = {};
|
|
43
|
-
this.hooks = {};
|
|
44
|
-
this.apps = null;
|
|
45
|
-
this.config = null;
|
|
46
|
-
|
|
47
|
-
this.validate = {
|
|
48
|
-
email(value) {
|
|
49
|
-
const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
50
|
-
if (!re.test(value)) {
|
|
51
|
-
return 'Please enter a valid e-mail';
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
},
|
|
55
|
-
url(value) {
|
|
56
|
-
const regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
|
|
57
|
-
if (regex.test(value)) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return 'Please enter a valid domain (e.g. http://domain.app:8001)';
|
|
62
|
-
},
|
|
63
|
-
writable(path) {
|
|
64
|
-
const error = 'Given path is not writable! Please check your permissions or specify a different file path.';
|
|
65
|
-
try {
|
|
66
|
-
// Check if file exists
|
|
67
|
-
fs.statSync(path).isFile();
|
|
68
|
-
try {
|
|
69
|
-
fs.accessSync(path, fs.W_OK);
|
|
70
|
-
return true;
|
|
71
|
-
} catch (err) {
|
|
72
|
-
return error;
|
|
73
|
-
}
|
|
74
|
-
} catch (err) {
|
|
75
|
-
// If file does not exist - try creating it, and remove it on success
|
|
76
|
-
try {
|
|
77
|
-
fs.ensureFileSync(path);
|
|
78
|
-
fs.removeSync(path);
|
|
79
|
-
} catch (err) {
|
|
80
|
-
return error;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
getConfig() {
|
|
89
|
-
if (this.config) {
|
|
90
|
-
return this.config;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
this.config = JSON.parse(this.readFile(this.projectRoot('webiny.json')));
|
|
95
|
-
} catch (e) {
|
|
96
|
-
this.config = {
|
|
97
|
-
lastRun: {
|
|
98
|
-
apps: [],
|
|
99
|
-
host: ''
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
return this.config;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
saveConfig(config) {
|
|
107
|
-
this.writeFile(this.projectRoot('webiny.json'), JSON.stringify(config, null, 4));
|
|
108
|
-
this.config = config;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
getPlugins(force = false) {
|
|
112
|
-
if (!force && Object.keys(this.plugins).length) {
|
|
113
|
-
return this.plugins;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const dir = this.projectRoot('Apps');
|
|
117
|
-
let files;
|
|
118
|
-
try {
|
|
119
|
-
files = this.shellExecute(`cd ${dir} && find . -maxdepth 2 -name "webiny.json"`, {stdio: 'pipe'});
|
|
120
|
-
} catch (err) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
this.plugins = {};
|
|
125
|
-
files = files.toString().split("\n").filter(line => line !== '');
|
|
126
|
-
|
|
127
|
-
// Sort files so that Webiny app file comes on top of the list
|
|
128
|
-
files.sort((a, b) => {
|
|
129
|
-
const w = './Webiny';
|
|
130
|
-
if (!a.startsWith(w) && b.startsWith(w)) {
|
|
131
|
-
return 1;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (a.startsWith(w) && !b.startsWith(w)) {
|
|
135
|
-
return -1;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return 0;
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
files.map(file => {
|
|
142
|
-
const webinyJson = this.projectRoot('Apps/' + file);
|
|
143
|
-
const wjson = JSON.parse(this.readFile(webinyJson));
|
|
144
|
-
if (_.has(wjson, 'cli.plugins') && _.isArray(wjson.cli.plugins)) {
|
|
145
|
-
wjson.cli.plugins.forEach(plPath => {
|
|
146
|
-
if (plPath.startsWith('./')) {
|
|
147
|
-
try {
|
|
148
|
-
const pluginClass = require(this.projectRoot('Apps/' + file.replace('webiny.json', plPath)));
|
|
149
|
-
this.plugins[pluginClass.task] = pluginClass;
|
|
150
|
-
} catch (e) {
|
|
151
|
-
// Ignore this file
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (_.has(wjson, 'cli.hooks') && _.isPlainObject(wjson.cli.hooks)) {
|
|
158
|
-
_.each(wjson.cli.hooks, (scripts, hook) => {
|
|
159
|
-
this.hooks[hook] = this.hooks[hook] || [];
|
|
160
|
-
scripts.forEach(script => {
|
|
161
|
-
if (script.startsWith('./')) {
|
|
162
|
-
script = this.projectRoot('Apps/' + file.replace('webiny.json', script))
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
this.hooks[hook].push(script);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Instantiate plugins
|
|
172
|
-
_.each(this.plugins, (pluginClass, name) => {
|
|
173
|
-
this.plugins[name] = new pluginClass(program);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
return this.plugins;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
getHooks(hook) {
|
|
180
|
-
return this.hooks[hook] || [];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Read platform apps
|
|
185
|
-
* @param app
|
|
186
|
-
* @param jsApp
|
|
187
|
-
* @returns {Array}
|
|
188
|
-
*/
|
|
189
|
-
getApps() {
|
|
190
|
-
if (!this.apps) {
|
|
191
|
-
this.apps = [];
|
|
192
|
-
}
|
|
193
|
-
const dir = this.projectRoot('Apps');
|
|
194
|
-
getFolders(dir).map(appSubfolder => {
|
|
195
|
-
const appDir = this.projectRoot('Apps/' + appSubfolder);
|
|
196
|
-
if (fs.existsSync(appDir + '/App.yaml')) {
|
|
197
|
-
const dir = appDir + '/Js';
|
|
198
|
-
// Read JS apps from given dir
|
|
199
|
-
readJsApps(appSubfolder, dir, this).map(appObj => {
|
|
200
|
-
this.apps.push(appObj);
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
return this.apps;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
projectRoot(path) {
|
|
209
|
-
if (!path) {
|
|
210
|
-
return fs.realpathSync(process.env.PWD);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return fs.realpathSync(process.env.PWD) + '/' + path;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
success(msg) {
|
|
217
|
-
let prefix = '';
|
|
218
|
-
if (msg.startsWith("\n")) {
|
|
219
|
-
prefix = "\n";
|
|
220
|
-
msg = _.trimStart(msg, "\n");
|
|
221
|
-
}
|
|
222
|
-
this.log(prefix + chalk.green('\u2713') + ' ' + msg);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
exclamation(msg, extra = null) {
|
|
226
|
-
let prefix = '';
|
|
227
|
-
if (msg.startsWith("\n")) {
|
|
228
|
-
prefix = "\n";
|
|
229
|
-
msg = _.trimStart(msg, "\n");
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
this.log(prefix + chalk.red('\u2757') + ' ' + msg);
|
|
233
|
-
|
|
234
|
-
if (extra) {
|
|
235
|
-
this.log(extra);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
failure(msg, extra = null) {
|
|
240
|
-
let prefix = '';
|
|
241
|
-
if (msg.startsWith("\n")) {
|
|
242
|
-
prefix = "\n";
|
|
243
|
-
msg = _.trimStart(msg, "\n");
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
this.log(prefix + chalk.red('\u2718') + ' ' + msg);
|
|
247
|
-
if (extra) {
|
|
248
|
-
this.log(extra);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
log(msg) {
|
|
253
|
-
console.log(msg);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
warning(msg) {
|
|
257
|
-
console.log('[' + chalk.red('WARNING') + ']: ' + msg);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
info(msg) {
|
|
261
|
-
let prefix = '';
|
|
262
|
-
if (msg.startsWith("\n")) {
|
|
263
|
-
prefix = "\n";
|
|
264
|
-
msg = _.trimStart(msg, "\n");
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
this.log(prefix + chalk.blue('>') + ' ' + msg);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
projectRoot(path) {
|
|
271
|
-
if (!path) {
|
|
272
|
-
return fs.realpathSync(process.env.PWD);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return fs.realpathSync(process.env.PWD) + '/' + path;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
fileExists(path) {
|
|
279
|
-
try {
|
|
280
|
-
return fs.statSync(path).isFile();
|
|
281
|
-
} catch (err) {
|
|
282
|
-
return false;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
isSymbolicLink(path) {
|
|
287
|
-
try {
|
|
288
|
-
return fs.lstatSync(path).isSymbolicLink();
|
|
289
|
-
} catch (err) {
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
folderExists(path) {
|
|
295
|
-
try {
|
|
296
|
-
return fs.statSync(path).isDirectory();
|
|
297
|
-
} catch (err) {
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
copy(from, to) {
|
|
303
|
-
try {
|
|
304
|
-
fs.copySync(from, to);
|
|
305
|
-
return true;
|
|
306
|
-
} catch (err) {
|
|
307
|
-
console.log(err);
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
readFile(path) {
|
|
313
|
-
return fs.readFileSync(path, 'utf8');
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
writeFile(file, data) {
|
|
317
|
-
fs.outputFileSync(file, data);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
deleteFile(file) {
|
|
321
|
-
fs.unlinkSync(file);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
shellExecute(cmd, options) {
|
|
325
|
-
options = options || {cwd: fs.realpathSync(process.env.PWD), env: process.env, stdio: 'inherit'};
|
|
326
|
-
return execSync(cmd, options);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
module.exports = new Webiny;
|
package/postinstall.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
const username = require('username');
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const binDir = './node_modules/.bin';
|
|
5
|
-
const Webiny = require('./lib/webiny');
|
|
6
|
-
const profilePath = process.platform === 'darwin' ? `/Users/${username.sync()}/profile` : `/home/${username.sync()}/.profile`;
|
|
7
|
-
const {magenta} = chalk;
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
let config = Webiny.readFile(profilePath);
|
|
11
|
-
|
|
12
|
-
if (config.match(binDir)) {
|
|
13
|
-
Webiny.info(`${magenta(profilePath)} already exports ${magenta(binDir)} to PATH.`);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
config += `# Added by webiny\nexport PATH="$PATH:${binDir}"`;
|
|
18
|
-
Webiny.writeFile(profilePath, config);
|
|
19
|
-
Webiny.success(`Added ${magenta('./node_modules/.bin')} executables to PATH in ${magenta(profilePath)}`);
|
|
20
|
-
Webiny.info('If not using Webiny vagrant box, please restart your shell or execute the export command yourself as follows:');
|
|
21
|
-
Webiny.info(magenta('export PATH="$PATH:./node_modules/.bin"'));
|
|
22
|
-
} catch (err) {
|
|
23
|
-
Webiny.failure('Could not export PATH!');
|
|
24
|
-
Webiny.log(err);
|
|
25
|
-
}
|
|
26
|
-
|