Merge pull request #2518 from abdonrd/fix-gae-deploy

Avoid write files if not development environment
This commit is contained in:
Jim LAURIE 2019-01-09 15:55:36 +01:00 committed by GitHub
commit 04a11ac18f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,7 @@
{ {
"host": "localhost", "host": "localhost",
"port": "${process.env.PORT || 1337}", "port": "${process.env.PORT || 1337}",
"production": true,
"proxy": { "proxy": {
"enabled": false "enabled": false
}, },

View File

@ -1,6 +1,7 @@
{ {
"host": "localhost", "host": "localhost",
"port": "${process.env.PORT || 1337}", "port": "${process.env.PORT || 1337}",
"production": true,
"proxy": { "proxy": {
"enabled": false "enabled": false
}, },

View File

@ -266,8 +266,10 @@ module.exports = {
resolvers, resolvers,
}); });
// Write schema. if (!strapi.config.currentEnvironment.server.production) {
this.writeGenerateSchema(graphql.printSchema(schema)); // Write schema.
this.writeGenerateSchema(graphql.printSchema(schema));
}
// Remove custom scaler (like Upload); // Remove custom scaler (like Upload);
typeDefs = Types.removeCustomScalar(typeDefs, resolvers); typeDefs = Types.removeCustomScalar(typeDefs, resolvers);

View File

@ -438,8 +438,10 @@ module.exports = {
try { try {
// Disable auto-reload. // Disable auto-reload.
strapi.reload.isWatching = false; strapi.reload.isWatching = false;
// Rewrite actions.json file. if (!strapi.config.currentEnvironment.server.production) {
fs.writeFileSync(actionsPath, JSON.stringify({ actions: data }), 'utf8'); // Rewrite actions.json file.
fs.writeFileSync(actionsPath, JSON.stringify({ actions: data }), 'utf8');
}
// Set value to AST to avoid restart. // Set value to AST to avoid restart.
_.set(strapi.plugins['users-permissions'], 'config.actions', data); _.set(strapi.plugins['users-permissions'], 'config.actions', data);
// Disable auto-reload. // Disable auto-reload.

View File

@ -88,12 +88,18 @@ module.exports = async function() {
return; return;
} }
const existBuildPath = await fs.pathExists(buildPath);
if (strapi.config.currentEnvironment.server.production && existBuildPath) {
return;
} else if (strapi.config.currentEnvironment.server.production && !existBuildPath) {
console.log('The plugins.json file is missing and the front-end cannot work without it. Please, create it first at development environment.');
}
// arrange system directories // arrange system directories
await Promise.all([ await Promise.all([
fs.remove(sourcePath), fs.remove(sourcePath),
(async () => { (async () => {
const existBuildPath = await fs.pathExists(buildPath);
if (existBuildPath) { if (existBuildPath) {
await fs.remove(buildPath); await fs.remove(buildPath);
} else { } else {