Use default build

Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
soupette 2021-12-20 14:56:06 +01:00
parent 3fae2a3fca
commit 584347e4bb
12 changed files with 6188 additions and 21 deletions

View File

@ -13,9 +13,6 @@
}, },
"dependencies": { "dependencies": {
"@strapi/admin": "4.0.0", "@strapi/admin": "4.0.0",
"@strapi/plugin-documentation": "4.0.0",
"@strapi/plugin-graphql": "4.0.0",
"@strapi/plugin-i18n": "4.0.0",
"@strapi/provider-email-mailgun": "4.0.0", "@strapi/provider-email-mailgun": "4.0.0",
"@strapi/provider-upload-aws-s3": "4.0.0", "@strapi/provider-upload-aws-s3": "4.0.0",
"@strapi/provider-upload-cloudinary": "4.0.0", "@strapi/provider-upload-cloudinary": "4.0.0",

View File

@ -0,0 +1,595 @@
{
"paths": {
"/email": {
"post": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"data": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"attributes": {
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
}
},
"meta": {
"type": "object"
}
}
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
}
},
"tags": [
"Email"
],
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"properties": {
"data": {
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
}
}
}
}
}
}
},
"/email/test": {
"post": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"data": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"attributes": {
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
}
},
"meta": {
"type": "object"
}
}
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
}
},
"tags": [
"Email"
],
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"properties": {
"data": {
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
}
}
}
}
}
}
},
"/email/settings": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"data": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"attributes": {
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
}
},
"meta": {
"type": "object"
}
}
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
}
},
"tags": [
"Email"
],
"parameters": [],
"requestBody": {}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -43,9 +43,10 @@ function getCustomWebpackConfig(dir, config) {
return webpackConfig; return webpackConfig;
} }
async function build({ plugins, dir, env, options, optimize }) { async function build({ plugins, dir, env, options, optimize, useDefaultBuild }) {
const buildAdmin = await shouldBuildAdmin({ dir, plugins }); const buildAdmin = await shouldBuildAdmin({ dir, plugins });
if (!buildAdmin) {
if (!buildAdmin && useDefaultBuild) {
return; return;
} }
@ -319,15 +320,14 @@ async function watchFiles(dir) {
} }
const hasCustomAdminCode = async dir => { const hasCustomAdminCode = async dir => {
const customAdminPath = path.join(dir, 'src/admin'); const customAdminPath = path.join(dir, 'src', 'admin');
const customAdminConfigFile = path.join(customAdminPath, 'app.js');
const customAdminWebpackFile = path.join(customAdminPath, 'webpack.config.js');
if (!(await fs.pathExists(customAdminPath))) { const hasCustomConfigFile = await fs.pathExists(customAdminConfigFile);
return false; const hasCustomWebpackFile = await fs.pathExists(customAdminWebpackFile);
}
const files = await fs.readdir(customAdminPath); return hasCustomConfigFile || hasCustomWebpackFile;
return files.length > 0;
}; };
const hasNonDefaultPlugins = plugins => { const hasNonDefaultPlugins = plugins => {

View File

@ -133,6 +133,7 @@ program
program program
.command('build') .command('build')
.option('--use-default-build', 'Use the default build of the admin panel', false)
.option('--clean', 'Remove the build and .cache folders', false) .option('--clean', 'Remove the build and .cache folders', false)
.option('--no-optimization', 'Build the Administration without assets optimization') .option('--no-optimization', 'Build the Administration without assets optimization')
.description('Builds the strapi admin app') .description('Builds the strapi admin app')

View File

@ -12,7 +12,7 @@ const getEnabledPlugins = require('../core/loaders/plugins/get-enabled-plugins')
/** /**
* `$ strapi build` * `$ strapi build`
*/ */
module.exports = async ({ clean, optimization }) => { module.exports = async ({ clean, optimization, useDefaultBuild }) => {
const dir = process.cwd(); const dir = process.cwd();
const strapiInstance = strapi({ const strapiInstance = strapi({
@ -36,6 +36,7 @@ module.exports = async ({ clean, optimization }) => {
return strapiAdmin return strapiAdmin
.build({ .build({
useDefaultBuild,
dir, dir,
plugins, plugins,
// front end build env is always production for now // front end build env is always production for now
@ -47,6 +48,8 @@ module.exports = async ({ clean, optimization }) => {
}, },
}) })
.then(() => { .then(() => {
console.log('Admin UI build successfully');
process.exit(); process.exit();
}) })
.catch(err => { .catch(err => {

View File

@ -15,7 +15,7 @@ const strapi = require('../index');
* `$ strapi develop` * `$ strapi develop`
* *
*/ */
module.exports = async function ({ build, watchAdmin, polling, browser }) { module.exports = async function({ build, watchAdmin, polling, browser }) {
const dir = process.cwd(); const dir = process.cwd();
const config = loadConfiguration(dir); const config = loadConfiguration(dir);
const logger = createLogger(config.logger, {}); const logger = createLogger(config.logger, {});
@ -28,7 +28,7 @@ module.exports = async function ({ build, watchAdmin, polling, browser }) {
// Don't run the build process if the admin is in watch mode // Don't run the build process if the admin is in watch mode
if (build && !watchAdmin && serveAdminPanel && !buildExists) { if (build && !watchAdmin && serveAdminPanel && !buildExists) {
try { try {
execa.sync('npm run -s build -- --no-optimization', { execa.sync('npm run -s build -- --no-optimization --use-default-build', {
stdio: 'inherit', stdio: 'inherit',
shell: true, shell: true,
}); });
@ -81,7 +81,7 @@ module.exports = async function ({ build, watchAdmin, polling, browser }) {
polling, polling,
}); });
process.on('message', async (message) => { process.on('message', async message => {
switch (message) { switch (message) {
case 'kill': case 'kill':
await strapiInstance.destroy(); await strapiInstance.destroy();
@ -140,15 +140,15 @@ function watchFileChanges({ dir, strapiInstance, watchIgnoreFiles, polling }) {
}); });
watcher watcher
.on('add', (path) => { .on('add', path => {
strapiInstance.log.info(`File created: ${path}`); strapiInstance.log.info(`File created: ${path}`);
restart(); restart();
}) })
.on('change', (path) => { .on('change', path => {
strapiInstance.log.info(`File changed: ${path}`); strapiInstance.log.info(`File changed: ${path}`);
restart(); restart();
}) })
.on('unlink', (path) => { .on('unlink', path => {
strapiInstance.log.info(`File deleted: ${path}`); strapiInstance.log.info(`File deleted: ${path}`);
restart(); restart();
}); });

View File

@ -2,7 +2,7 @@ export default {
config: { config: {
locales: [ locales: [
// 'ar', // 'ar',
'fr', // 'fr',
// 'cs', // 'cs',
// 'de', // 'de',
// 'dk', // 'dk',
@ -29,5 +29,7 @@ export default {
// 'zh', // 'zh',
], ],
}, },
bootstrap() {}, bootstrap(app) {
console.log(app);
},
}; };