@strapi/admin 4.2.0 → 4.3.0-beta.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/admin/src/app.js +7 -4
- package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +3 -3
- package/admin/src/content-manager/components/SelectMany/index.js +2 -4
- package/admin/src/content-manager/components/SelectWrapper/index.js +1 -13
- package/admin/src/hooks/useFetchMarketplaceProviders/index.js +1 -1
- package/admin/src/pages/Admin/index.js +15 -5
- package/admin/src/pages/App/constants.js +1 -0
- package/admin/src/pages/App/index.js +17 -3
- package/admin/src/pages/App/reducer.js +22 -0
- package/admin/src/pages/MarketplacePage/components/NpmPackagesGrid/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/components/LogoModalStepper/FromUrlForm.js +7 -3
- package/admin/src/reducers.js +4 -2
- package/admin/src/tsconfig.json +10 -0
- package/build/{9158.e48d88af.chunk.js → 1820.ca954075.chunk.js} +31 -31
- package/build/20.9e5a98b6.chunk.js +308 -0
- package/build/3531.231e0eb6.chunk.js +10 -0
- package/build/{9115.abdf4e3b.chunk.js → 4073.e144a91a.chunk.js} +1 -1
- package/build/413.d5986568.chunk.js +284 -0
- package/build/{7757.f6eb5e92.chunk.js → 472.d43be8bb.chunk.js} +2 -2
- package/build/5250.24040688.chunk.js +11 -0
- package/build/6229.53b33cf0.chunk.js +194 -0
- package/build/7418.6db737ce.chunk.js +112 -0
- package/build/8773.54a26ded.chunk.js +327 -0
- package/build/9262.25aa12a5.chunk.js +1 -0
- package/build/Admin-authenticatedApp.52f3c150.chunk.js +80 -0
- package/build/{Admin_homePage.8c00145e.chunk.js → Admin_homePage.0ac648e8.chunk.js} +1 -1
- package/build/{Admin_marketplace.a88d5bda.chunk.js → Admin_marketplace.71c66b49.chunk.js} +2 -2
- package/build/Admin_pluginsPage.788fb2f6.chunk.js +1 -0
- package/build/{Admin_profilePage.33cfed9b.chunk.js → Admin_profilePage.27191ed2.chunk.js} +2 -2
- package/build/Admin_settingsPage.021da806.chunk.js +178 -0
- package/build/{admin-edit-roles-page.e77a2acc.chunk.js → admin-edit-roles-page.fb374555.chunk.js} +1 -1
- package/build/admin-edit-users.a360deaf.chunk.js +10 -0
- package/build/admin-users.47d06d24.chunk.js +11 -0
- package/build/{api-tokens-create-page.618b3e40.chunk.js → api-tokens-create-page.698f132d.chunk.js} +1 -1
- package/build/{api-tokens-edit-page.8d19dfe1.chunk.js → api-tokens-edit-page.afece2fe.chunk.js} +1 -1
- package/build/{api-tokens-list-page.274e1c80.chunk.js → api-tokens-list-page.46d96dee.chunk.js} +1 -1
- package/build/{codemirror-css.98490df3.chunk.js → codemirror-css.b467b1de.chunk.js} +2 -2
- package/build/{codemirror-javacript.cafbda9c.chunk.js → codemirror-javacript.41bdefda.chunk.js} +1 -1
- package/build/codemirror-theme.cf9f9eb6.chunk.js +34 -0
- package/build/content-manager.afcc3624.chunk.js +1182 -0
- package/build/content-type-builder.e73879b9.chunk.js +141 -0
- package/build/{cropper-css.0055cd53.chunk.js → cropper-css.ecc0d670.chunk.js} +2 -2
- package/build/{email-settings-page.4ae595f6.chunk.js → email-settings-page.8871dfe8.chunk.js} +2 -2
- package/build/{fontawesome-css-all.b88d464e.chunk.js → fontawesome-css-all.04f33619.chunk.js} +3 -3
- package/build/{fontawesome-css.59dc4459.chunk.js → fontawesome-css.477ba714.chunk.js} +2 -2
- package/build/highlight.js.3381ffc3.chunk.js +86 -0
- package/build/{i18n-settings-page.bdac3c7b.chunk.js → i18n-settings-page.dfb4eb01.chunk.js} +1 -1
- package/build/index.html +1 -1
- package/build/main.ca3856ed.js +8640 -0
- package/build/{runtime~main.de49adfd.js → runtime~main.48a46dd2.js} +1 -1
- package/build/sso-settings-page.dfb0b917.chunk.js +1 -0
- package/build/{upload-settings.cadfd452.chunk.js → upload-settings.8d8c672a.chunk.js} +1 -1
- package/build/upload-translation-de-json.745613c0.chunk.js +1 -0
- package/build/upload-translation-dk-json.cb25dcf0.chunk.js +1 -0
- package/build/upload-translation-en-json.e78688a0.chunk.js +1 -0
- package/build/upload-translation-es-json.1f344b53.chunk.js +1 -0
- package/build/upload-translation-fr-json.e21c0c7a.chunk.js +1 -0
- package/build/upload-translation-he-json.4ce77b7b.chunk.js +1 -0
- package/build/upload-translation-it-json.5ce11e0b.chunk.js +1 -0
- package/build/upload-translation-ja-json.22afae44.chunk.js +1 -0
- package/build/upload-translation-ko-json.9a2c21cb.chunk.js +1 -0
- package/build/upload-translation-ms-json.0605d6da.chunk.js +1 -0
- package/build/upload-translation-pl-json.e534b676.chunk.js +1 -0
- package/build/upload-translation-pt-BR-json.95686cfb.chunk.js +1 -0
- package/build/upload-translation-ru-json.37bd1546.chunk.js +1 -0
- package/build/upload-translation-sk-json.b03d4904.chunk.js +1 -0
- package/build/upload-translation-th-json.64dd70ce.chunk.js +1 -0
- package/build/upload-translation-uk-json.1328cb3e.chunk.js +1 -0
- package/build/{upload-translation-zh-Hans-json.c9622577.chunk.js → upload-translation-zh-Hans-json.6832ff81.chunk.js} +1 -1
- package/build/upload-translation-zh-json.ee8fba96.chunk.js +1 -0
- package/build/upload.5622b777.chunk.js +7 -0
- package/build/{users-advanced-settings-page.646b6f29.chunk.js → users-advanced-settings-page.4af9e241.chunk.js} +1 -1
- package/build/users-email-settings-page.d69c0d87.chunk.js +101 -0
- package/build/users-providers-settings-page.fc1fda6d.chunk.js +101 -0
- package/build/{users-roles-settings-page.28bf6bdc.chunk.js → users-roles-settings-page.988ebc3b.chunk.js} +2 -2
- package/build/{webhook-edit-page.ca670f8d.chunk.js → webhook-edit-page.a7ae6e3b.chunk.js} +2 -2
- package/build/{webhook-list-page.7057f1e8.chunk.js → webhook-list-page.057f396c.chunk.js} +1 -1
- package/index.js +47 -239
- package/package.json +10 -5
- package/scripts/build.js +19 -3
- package/server/controllers/admin.js +21 -0
- package/server/policies/index.js +1 -0
- package/server/policies/isTelemetryEnabled.js +16 -0
- package/server/routes/admin.js +8 -0
- package/server/routes/serve-admin-panel.js +1 -1
- package/utils/create-cache-dir.js +131 -0
- package/utils/get-custom-app-config-file.js +28 -0
- package/utils/get-custom-webpack-config.js +38 -0
- package/utils/get-plugins-path.js +26 -0
- package/utils/index.js +13 -0
- package/utils/should-build-admin.js +52 -0
- package/utils/watch-admin-files.js +59 -0
- package/webpack.config.js +28 -5
- package/admin/src/content-manager/components/SelectWrapper/ClearIndicator.js +0 -18
- package/admin/src/content-manager/components/SelectWrapper/DropdownIndicator.js +0 -24
- package/admin/src/content-manager/components/SelectWrapper/IconBox.js +0 -20
- package/admin/src/content-manager/components/SelectWrapper/IndicatorSeparator.js +0 -3
- package/admin/src/content-manager/components/SelectWrapper/utils/getSelectStyles.js +0 -92
- package/build/2758.9475712b.chunk.js +0 -162
- package/build/2912.dd031292.chunk.js +0 -253
- package/build/4982.c57c5675.chunk.js +0 -308
- package/build/7197.ed8d6752.chunk.js +0 -113
- package/build/7589.577cf729.chunk.js +0 -194
- package/build/7841.9e9cf739.chunk.js +0 -253
- package/build/8681.aec05472.chunk.js +0 -163
- package/build/9298.cb3b6bc1.chunk.js +0 -334
- package/build/948.d64fb515.chunk.js +0 -2
- package/build/Admin-authenticatedApp.e7ed0550.chunk.js +0 -80
- package/build/Admin_pluginsPage.e895d79f.chunk.js +0 -1
- package/build/Admin_settingsPage.fe33e0a2.chunk.js +0 -180
- package/build/admin-edit-users.4c49fe98.chunk.js +0 -11
- package/build/admin-users.b89adf82.chunk.js +0 -12
- package/build/codemirror-theme.b3c64617.chunk.js +0 -34
- package/build/content-manager.04b93497.chunk.js +0 -1204
- package/build/content-type-builder.b3139cb1.chunk.js +0 -141
- package/build/highlight.js.9d8ef460.chunk.js +0 -86
- package/build/main.3257934a.js +0 -8404
- package/build/sso-settings-page.0b4d2106.chunk.js +0 -1
- package/build/upload-translation-de-json.b642da08.chunk.js +0 -1
- package/build/upload-translation-dk-json.fc61df13.chunk.js +0 -1
- package/build/upload-translation-en-json.59269508.chunk.js +0 -1
- package/build/upload-translation-es-json.8ec935ef.chunk.js +0 -1
- package/build/upload-translation-fr-json.eb9b4f84.chunk.js +0 -1
- package/build/upload-translation-he-json.c226f2dc.chunk.js +0 -1
- package/build/upload-translation-it-json.8e58456e.chunk.js +0 -1
- package/build/upload-translation-ja-json.1378a2e7.chunk.js +0 -1
- package/build/upload-translation-ko-json.5e06e112.chunk.js +0 -1
- package/build/upload-translation-ms-json.dc3bf0d7.chunk.js +0 -1
- package/build/upload-translation-pl-json.6071e38c.chunk.js +0 -1
- package/build/upload-translation-pt-BR-json.7e8d9550.chunk.js +0 -1
- package/build/upload-translation-ru-json.da2529f3.chunk.js +0 -1
- package/build/upload-translation-sk-json.bfdf4f09.chunk.js +0 -1
- package/build/upload-translation-th-json.6a48b826.chunk.js +0 -1
- package/build/upload-translation-uk-json.6fb09148.chunk.js +0 -1
- package/build/upload-translation-zh-json.711f804b.chunk.js +0 -1
- package/build/upload.fbc65439.chunk.js +0 -105
- package/build/users-email-settings-page.8b561ea3.chunk.js +0 -1
- package/build/users-providers-settings-page.82141ace.chunk.js +0 -1
|
@@ -130,4 +130,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
130
130
|
flex-wrap: `,`;
|
|
131
131
|
`,`};
|
|
132
132
|
justify-content: `,`;
|
|
133
|
-
`])),function(t){return t.alignItems},function(t){return t.inline?"inline-flex":"flex"},function(t){return t.direction},function(t){return t.wrap},function(t){var d=t.gap,j=t.theme;return Object(m.a)("gap",d,j)},function(t){return t.justifyContent});e.defaultProps=k,e.propTypes=L}})})},
|
|
133
|
+
`])),function(t){return t.alignItems},function(t){return t.inline?"inline-flex":"flex"},function(t){return t.direction},function(t){return t.wrap},function(t){var d=t.gap,j=t.theme;return Object(m.a)("gap",d,j)},function(t){return t.justifyContent});e.defaultProps=k,e.propTypes=L}})})},54999:(V,z,p)=>{"use strict";p.r(z),p.d(z,{default:()=>Ee});var i=p(32735),w=p(10938),o=p(2805),b=p(5141),n=p(5636),a=p(11856),r=p(64354),u=p(19192),l=p(90662),f=p(20763),c=p(35980),m=p(53214),E=p(95602),C=p(44526),s=p(28004),y=p(55470),S=p(16540),k=p(29270),L=p(9808),D=p(59290),e=p.n(D),t=p(95717),d=p.n(t),j=p(76470),B=p.n(j),O=p(97042),_=p.n(O),ee=p(49415),ne=p(3040),G=p.n(ne);const $={webhooks:[],webhooksToDelete:[],webhookToDelete:null,loadingWebhooks:!0},Q=(x,v)=>(0,ee.default)(x,g=>{switch(v.type){case"GET_DATA_SUCCEEDED":{g.webhooks=v.data,g.loadingWebhooks=!1;break}case"TOGGLE_LOADING":{g.loadingWebhooks=!x.loadingWebhooks;break}case"SET_WEBHOOK_ENABLED":{G()(g,["webhooks",...v.keys],v.value);break}case"SET_WEBHOOK_TO_DELETE":{g.webhookToDelete=v.id;break}case"SET_WEBHOOKS_TO_DELETE":{v.value?g.webhooksToDelete.push(v.id):g.webhooksToDelete=x.webhooksToDelete.filter(P=>P!==v.id);break}case"SET_ALL_WEBHOOKS_TO_DELETE":{x.webhooksToDelete.length===0?g.webhooksToDelete=x.webhooks.map(P=>P.id):g.webhooksToDelete=[];break}case"WEBHOOKS_DELETED":{g.webhooks=x.webhooks.filter(P=>!x.webhooksToDelete.includes(P.id)),g.webhooksToDelete=[];break}case"WEBHOOK_DELETED":{g.webhooks=x.webhooks.filter((P,H)=>H!==v.index),g.webhookToDelete=null;break}default:return g}});var te=p(98399),pe=Object.defineProperty,he=Object.defineProperties,me=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,ie=(x,v,g)=>v in x?pe(x,v,{enumerable:!0,configurable:!0,writable:!0,value:g}):x[v]=g,F=(x,v)=>{for(var g in v||(v={}))be.call(v,g)&&ie(x,g,v[g]);if(ae)for(var g of ae(v))ge.call(v,g)&&ie(x,g,v[g]);return x},ve=(x,v)=>he(x,me(v)),X=(x,v,g)=>new Promise((P,H)=>{var N=A=>{try{T(g.next(A))}catch(R){H(R)}},W=A=>{try{T(g.throw(A))}catch(R){H(R)}},T=A=>A.done?P(A.value):Promise.resolve(A.value).then(N,W);T((g=g.apply(x,v)).next())});const ye=()=>{const{isLoading:x,allowedActions:{canCreate:v,canRead:g,canUpdate:P,canDelete:H}}=(0,w.useRBAC)(o.Z.settings.webhooks),N=(0,w.useNotification)(),W=(0,i.useRef)(!0),{formatMessage:T}=(0,n.useIntl)(),[A,R]=(0,i.useState)(!1),[{webhooks:Z,webhooksToDelete:Y,webhookToDelete:oe,loadingWebhooks:re},I]=(0,i.useReducer)(Q,$),{notifyStatus:xe}=(0,k.useNotifyAT)();(0,w.useFocusWhenNavigate)();const{push:Te}=(0,b.useHistory)(),{pathname:se}=(0,b.useLocation)(),J=Z.length,K=Y.length,le=h=>Z.findIndex(M=>M.id===h);(0,i.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]),(0,i.useEffect)(()=>{g&&Oe()},[g]);const Oe=()=>X(void 0,null,function*(){try{const{data:h}=yield(0,w.request)("/admin/webhooks",{method:"GET"});W.current&&(I({type:"GET_DATA_SUCCEEDED",data:h}),xe("webhooks have been loaded"))}catch(h){te.log(h),W.current&&(h.code!==20&&N({type:"warning",message:{id:"notification.error"}}),I({type:"TOGGLE_LOADING"}))}}),we=()=>{R(h=>!h)},Se=()=>{oe?ke():Le()},ke=()=>X(void 0,null,function*(){try{yield(0,w.request)(`/admin/webhooks/${oe}`,{method:"DELETE"}),I({type:"WEBHOOK_DELETED",index:le(oe)})}catch(h){h.code!==20&&N({type:"warning",message:{id:"notification.error"}})}R(!1)}),Le=()=>X(void 0,null,function*(){const h={ids:Y};try{yield(0,w.request)("/admin/webhooks/batch-delete",{method:"POST",body:h}),W.current&&I({type:"WEBHOOKS_DELETED"})}catch(M){W.current&&M.code!==20&&N({type:"warning",message:{id:"notification.error"}})}R(!1)}),ue=h=>{R(!0),h!=="all"&&I({type:"SET_WEBHOOK_TO_DELETE",id:h})},Ce=(h,M)=>X(void 0,null,function*(){const ce=le(M),Me=Z[ce],de=[ce,"isEnabled"],fe=ve(F({},Me),{isEnabled:h});delete fe.id;try{I({type:"SET_WEBHOOK_ENABLED",keys:de,value:h}),yield(0,w.request)(`/admin/webhooks/${M}`,{method:"PUT",body:fe})}catch(je){W.current&&(I({type:"SET_WEBHOOK_ENABLED",keys:de,value:!h}),je.code!==20&&N({type:"warning",message:{id:"notification.error"}}))}}),De=()=>{I({type:"SET_ALL_WEBHOOKS_TO_DELETE"})},Pe=(h,M)=>{I({type:"SET_WEBHOOKS_TO_DELETE",value:h,id:M})},q=h=>{Te(`${se}/${h}`)};return i.createElement(a.Layout,null,i.createElement(w.SettingsPageTitle,{name:"Webhooks"}),i.createElement(S.Main,{"aria-busy":x||re},i.createElement(a.HeaderLayout,{title:T({id:"Settings.webhooks.title",defaultMessage:"Webhooks"}),subtitle:T({id:"Settings.webhooks.list.description",defaultMessage:"Get POST changes notifications"}),primaryAction:v&&!re&&i.createElement(w.LinkButton,{startIcon:i.createElement(e(),null),variant:"default",to:`${se}/create`,size:"L"},T({id:"Settings.webhooks.list.button.add",defaultMessage:"Create new webhook"}))}),K>0&&H&&i.createElement(a.ActionLayout,{startActions:i.createElement(i.Fragment,null,i.createElement(E.Typography,{variant:"epsilon",textColor:"neutral600"},T({id:"Settings.webhooks.to.delete",defaultMessage:"{webhooksToDeleteLength, plural, one {# asset} other {# assets}} selected"},{webhooksToDeleteLength:K})),i.createElement(C.Button,{onClick:()=>ue("all"),startIcon:i.createElement(B(),null),size:"L",variant:"danger-light"},T({id:"global.delete",defaultMessage:"Delete"})))}),i.createElement(a.ContentLayout,null,x||re?i.createElement(L.Box,{background:"neutral0",padding:6,shadow:"filterShadow",hasRadius:!0},i.createElement(w.LoadingIndicatorPage,null)):i.createElement(i.Fragment,null,J>0?i.createElement(m.Table,{colCount:5,rowCount:J+1,footer:i.createElement(m.TFooter,{onClick:()=>v?q("create"):{},icon:i.createElement(e(),null)},T({id:"Settings.webhooks.list.button.add",defaultMessage:"Create new webhook"}))},i.createElement(m.Thead,null,i.createElement(m.Tr,null,i.createElement(m.Th,null,i.createElement(c.BaseCheckbox,{"aria-label":T({id:"global.select-all-entries",defaultMessage:"Select all entries"}),indeterminate:K>0&&K<J,value:K===J,onValueChange:De})),i.createElement(m.Th,{width:"20%"},i.createElement(E.Typography,{variant:"sigma",textColor:"neutral600"},T({id:"global.name",defaultMessage:"Name"}))),i.createElement(m.Th,{width:"60%"},i.createElement(E.Typography,{variant:"sigma",textColor:"neutral600"},T({id:"Settings.webhooks.form.url",defaultMessage:"URL"}))),i.createElement(m.Th,{width:"20%"},i.createElement(E.Typography,{variant:"sigma",textColor:"neutral600"},T({id:"Settings.webhooks.list.th.status",defaultMessage:"Status"}))),i.createElement(m.Th,null,i.createElement(s.VisuallyHidden,null,T({id:"Settings.webhooks.list.th.actions",defaultMessage:"Actions"}))))),i.createElement(m.Tbody,null,Z.map(h=>i.createElement(m.Tr,F({key:h.id},(0,w.onRowClick)({fn:()=>q(h.id),condition:P})),i.createElement(m.Td,F({},w.stopPropagation),i.createElement(c.BaseCheckbox,{"aria-label":`${T({id:"global.select",defaultMessage:"Select"})} ${h.name}`,value:Y==null?void 0:Y.includes(h.id),onValueChange:M=>Pe(M,h.id),id:"select",name:"select"})),i.createElement(m.Td,null,i.createElement(E.Typography,{fontWeight:"semiBold",textColor:"neutral800"},h.name)),i.createElement(m.Td,null,i.createElement(E.Typography,{textColor:"neutral800"},h.url)),i.createElement(m.Td,null,i.createElement(u.Flex,F({},w.stopPropagation),i.createElement(y.Switch,{onLabel:T({id:"global.enabled",defaultMessage:"Enabled"}),offLabel:T({id:"global.disabled",defaultMessage:"Disabled"}),label:`${h.name} ${T({id:"Settings.webhooks.list.th.status",defaultMessage:"Status"})}`,selected:h.isEnabled,onChange:()=>Ce(!h.isEnabled,h.id),visibleLabels:!0}))),i.createElement(m.Td,null,i.createElement(l.Stack,F({horizontal:!0,spacing:1},w.stopPropagation),P&&i.createElement(f.IconButton,{onClick:()=>{q(h.id)},label:T({id:"Settings.webhooks.events.update",defaultMessage:"Update"}),icon:i.createElement(d(),null),noBorder:!0}),H&&i.createElement(f.IconButton,{onClick:()=>ue(h.id),label:T({id:"global.delete",defaultMessage:"Delete"}),icon:i.createElement(B(),null),noBorder:!0,id:`delete-${h.id}`}))))))):i.createElement(r.EmptyStateLayout,{icon:i.createElement(_(),{width:"160px"}),content:T({id:"Settings.webhooks.list.empty.description",defaultMessage:"No webhooks found"}),action:i.createElement(C.Button,{variant:"secondary",startIcon:i.createElement(e(),null),onClick:()=>v?q("create"):{}},T({id:"Settings.webhooks.list.button.add",defaultMessage:"Create new webhook"}))})))),i.createElement(w.ConfirmDialog,{isOpen:A,onToggleDialog:we,onConfirm:Se}))},Ee=()=>i.createElement(w.CheckPagePermissions,{permissions:o.Z.settings.webhooks.main},i.createElement(ye,null))}}]);
|
package/index.js
CHANGED
|
@@ -1,66 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const _ = require('lodash');
|
|
5
4
|
const fs = require('fs-extra');
|
|
6
5
|
const webpack = require('webpack');
|
|
7
6
|
const WebpackDevServer = require('webpack-dev-server');
|
|
7
|
+
const { isUsingTypeScript } = require('@strapi/typescript-utils');
|
|
8
8
|
const chalk = require('chalk');
|
|
9
|
-
const chokidar = require('chokidar');
|
|
10
|
-
const getWebpackConfig = require('./webpack.config');
|
|
11
9
|
|
|
12
|
-
const
|
|
10
|
+
const {
|
|
11
|
+
createCacheDir,
|
|
12
|
+
getCustomWebpackConfig,
|
|
13
|
+
shouldBuildAdmin,
|
|
14
|
+
watchAdminFiles,
|
|
15
|
+
} = require('./utils');
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'content-manager',
|
|
17
|
-
'upload',
|
|
18
|
-
'email',
|
|
19
|
-
'i18n',
|
|
20
|
-
'users-permissions',
|
|
21
|
-
];
|
|
17
|
+
async function build({ appDir, buildDestDir, env, forceBuild, optimize, options, plugins }) {
|
|
18
|
+
const buildAdmin = await shouldBuildAdmin({ appDir, plugins });
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
const adminConfigPath = path.join(dir, 'src', 'admin', 'webpack.config.js');
|
|
25
|
-
|
|
26
|
-
let webpackConfig = getWebpackConfig(config);
|
|
27
|
-
|
|
28
|
-
if (fs.existsSync(adminConfigPath)) {
|
|
29
|
-
const webpackAdminConfig = require(path.resolve(adminConfigPath));
|
|
30
|
-
|
|
31
|
-
if (_.isFunction(webpackAdminConfig)) {
|
|
32
|
-
// Expose the devServer configuration
|
|
33
|
-
if (config.devServer) {
|
|
34
|
-
webpackConfig.devServer = config.devServer;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
webpackConfig = webpackAdminConfig(webpackConfig, webpack);
|
|
38
|
-
|
|
39
|
-
if (!webpackConfig) {
|
|
40
|
-
console.error(
|
|
41
|
-
`${chalk.red('Error:')} Nothing was returned from your custom webpack configuration`
|
|
42
|
-
);
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return webpackConfig;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function build({ plugins, dir, env, options, optimize, forceBuild }) {
|
|
52
|
-
const buildAdmin = await shouldBuildAdmin({ dir, plugins });
|
|
20
|
+
const useTypeScript = await isUsingTypeScript(path.join(appDir, 'src', 'admin'), 'tsconfig.json');
|
|
53
21
|
|
|
54
22
|
if (!buildAdmin && !forceBuild) {
|
|
55
23
|
return;
|
|
56
24
|
}
|
|
57
25
|
|
|
58
26
|
// Create the cache dir containing the front-end files.
|
|
59
|
-
await createCacheDir({
|
|
27
|
+
await createCacheDir({ appDir, plugins });
|
|
60
28
|
|
|
61
|
-
const cacheDir = path.resolve(
|
|
29
|
+
const cacheDir = path.resolve(appDir, '.cache');
|
|
62
30
|
const entry = path.resolve(cacheDir, 'admin', 'src');
|
|
63
|
-
const dest = path.resolve(
|
|
31
|
+
const dest = path.resolve(buildDestDir, 'build');
|
|
64
32
|
|
|
65
33
|
// Roots for the @strapi/babel-plugin-switch-ee-ce
|
|
66
34
|
const roots = {
|
|
@@ -70,15 +38,23 @@ async function build({ plugins, dir, env, options, optimize, forceBuild }) {
|
|
|
70
38
|
|
|
71
39
|
const pluginsPath = Object.keys(plugins).map(pluginName => plugins[pluginName].pathToPlugin);
|
|
72
40
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
41
|
+
// Either use the tsconfig file from the generated app or the one inside the .cache folder
|
|
42
|
+
// so we can develop plugins in TS while being in a JS app
|
|
43
|
+
const tsConfigFilePath = useTypeScript
|
|
44
|
+
? path.join(appDir, 'src', 'admin', 'tsconfig.json')
|
|
45
|
+
: path.resolve(entry, 'tsconfig.json');
|
|
46
|
+
|
|
47
|
+
const config = getCustomWebpackConfig(appDir, {
|
|
48
|
+
appDir,
|
|
76
49
|
cacheDir,
|
|
77
50
|
dest,
|
|
51
|
+
entry,
|
|
78
52
|
env,
|
|
79
|
-
options,
|
|
80
53
|
optimize,
|
|
54
|
+
options,
|
|
55
|
+
pluginsPath,
|
|
81
56
|
roots,
|
|
57
|
+
tsConfigFilePath,
|
|
82
58
|
});
|
|
83
59
|
|
|
84
60
|
const compiler = webpack(config);
|
|
@@ -109,115 +85,24 @@ async function build({ plugins, dir, env, options, optimize, forceBuild }) {
|
|
|
109
85
|
});
|
|
110
86
|
}
|
|
111
87
|
|
|
112
|
-
async function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
* path.join, on windows, it uses backslashes to resolve path.
|
|
118
|
-
* The problem is that Webpack does not windows paths
|
|
119
|
-
* With this tool, we need to rely on "/" and not "\".
|
|
120
|
-
* This is the reason why '..\\..\\..\\node_modules\\@strapi\\plugin-content-type-builder/strapi-admin.js' was not working.
|
|
121
|
-
* The regexp at line 105 aims to replace the windows backslashes by standard slash so that webpack can deal with them.
|
|
122
|
-
* Backslash looks to work only for absolute paths with webpack => https://webpack.js.org/concepts/module-resolution/#absolute-paths
|
|
123
|
-
*/
|
|
124
|
-
const realPath = path
|
|
125
|
-
.join(path.relative(path.resolve(dest, 'admin', 'src'), pathToPlugin), 'strapi-admin.js')
|
|
126
|
-
.replace(/\\/g, '/');
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
name,
|
|
130
|
-
pathToPlugin: realPath,
|
|
131
|
-
shortName,
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const content = `
|
|
136
|
-
${pluginsArray
|
|
137
|
-
.map(({ pathToPlugin, shortName }) => {
|
|
138
|
-
const req = `'${pathToPlugin}'`;
|
|
139
|
-
|
|
140
|
-
return `import ${shortName} from ${req};`;
|
|
141
|
-
})
|
|
142
|
-
.join('\n')}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const plugins = {
|
|
146
|
-
${[...pluginsArray]
|
|
147
|
-
.map(({ name, shortName }) => {
|
|
148
|
-
return ` '${name}': ${shortName},`;
|
|
149
|
-
})
|
|
150
|
-
.join('\n')}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export default plugins;
|
|
154
|
-
`;
|
|
155
|
-
|
|
156
|
-
return fs.writeFile(path.resolve(dest, 'admin', 'src', 'plugins.js'), content);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
async function clean({ dir }) {
|
|
160
|
-
const buildDir = path.join(dir, 'build');
|
|
161
|
-
const cacheDir = path.join(dir, '.cache');
|
|
88
|
+
async function clean({ appDir, buildDestDir }) {
|
|
89
|
+
// FIXME rename admin build dir and path to build dir
|
|
90
|
+
const buildDir = path.join(buildDestDir, 'build');
|
|
91
|
+
// .cache dir is always located at the root of the app
|
|
92
|
+
const cacheDir = path.join(appDir, '.cache');
|
|
162
93
|
|
|
163
94
|
fs.removeSync(buildDir);
|
|
164
95
|
fs.removeSync(cacheDir);
|
|
165
96
|
}
|
|
166
97
|
|
|
167
|
-
async function
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
// TODO copy ee folders for plugins
|
|
171
|
-
await fs.copy(path.resolve(adminPath, 'ee', 'admin'), path.resolve(dest, 'ee', 'admin'));
|
|
172
|
-
|
|
173
|
-
await fs.ensureDir(path.resolve(dest, 'config'));
|
|
174
|
-
await fs.copy(path.resolve(adminPath, 'admin'), path.resolve(dest, 'admin'));
|
|
175
|
-
|
|
176
|
-
// Copy package.json
|
|
177
|
-
await fs.copy(path.resolve(adminPath, 'package.json'), path.resolve(dest, 'package.json'));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
async function createCacheDir({ dir, plugins }) {
|
|
181
|
-
const cacheDir = path.resolve(dir, '.cache');
|
|
182
|
-
|
|
183
|
-
const pluginsWithFront = Object.keys(plugins)
|
|
184
|
-
.filter(pluginName => {
|
|
185
|
-
const pluginInfo = plugins[pluginName];
|
|
186
|
-
return fs.existsSync(path.resolve(pluginInfo.pathToPlugin, 'strapi-admin.js'));
|
|
187
|
-
})
|
|
188
|
-
.map(name => ({ name, ...plugins[name] }));
|
|
189
|
-
|
|
190
|
-
// create .cache dir
|
|
191
|
-
await fs.emptyDir(cacheDir);
|
|
192
|
-
|
|
193
|
-
// copy admin core code
|
|
194
|
-
await copyAdmin(cacheDir);
|
|
195
|
-
|
|
196
|
-
// Copy app.js
|
|
197
|
-
const customAdminConfigFilePath = path.join(dir, 'src', 'admin', 'app.js');
|
|
198
|
-
|
|
199
|
-
if (fs.existsSync(customAdminConfigFilePath)) {
|
|
200
|
-
await fs.copy(customAdminConfigFilePath, path.resolve(cacheDir, 'admin', 'src', 'app.js'));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Copy admin extensions folder
|
|
204
|
-
const adminExtensionFolder = path.join(dir, 'src', 'admin', 'extensions');
|
|
205
|
-
|
|
206
|
-
if (fs.existsSync(adminExtensionFolder)) {
|
|
207
|
-
await fs.copy(adminExtensionFolder, path.resolve(cacheDir, 'admin', 'src', 'extensions'));
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// create plugins.js with plugins requires
|
|
211
|
-
await createPluginsJs(pluginsWithFront, cacheDir);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
async function watchAdmin({ plugins, dir, host, port, browser, options }) {
|
|
98
|
+
async function watchAdmin({ appDir, browser, buildDestDir, host, options, plugins, port }) {
|
|
99
|
+
const useTypeScript = await isUsingTypeScript(path.join(appDir, 'src', 'admin'), 'tsconfig.json');
|
|
215
100
|
// Create the cache dir containing the front-end files.
|
|
216
|
-
const cacheDir = path.join(
|
|
217
|
-
await createCacheDir({
|
|
101
|
+
const cacheDir = path.join(appDir, '.cache');
|
|
102
|
+
await createCacheDir({ appDir, plugins });
|
|
218
103
|
|
|
219
104
|
const entry = path.join(cacheDir, 'admin', 'src');
|
|
220
|
-
const dest = path.join(
|
|
105
|
+
const dest = path.join(buildDestDir, 'build');
|
|
221
106
|
const env = 'development';
|
|
222
107
|
|
|
223
108
|
// Roots for the @strapi/babel-plugin-switch-ee-ce
|
|
@@ -228,14 +113,20 @@ async function watchAdmin({ plugins, dir, host, port, browser, options }) {
|
|
|
228
113
|
|
|
229
114
|
const pluginsPath = Object.keys(plugins).map(pluginName => plugins[pluginName].pathToPlugin);
|
|
230
115
|
|
|
116
|
+
// Either use the tsconfig file from the generated app or the one inside the .cache folder
|
|
117
|
+
// so we can develop plugins in TS while being in a JS app
|
|
118
|
+
const tsConfigFilePath = useTypeScript
|
|
119
|
+
? path.join(appDir, 'src', 'admin', 'tsconfig.json')
|
|
120
|
+
: path.resolve(entry, 'tsconfig.json');
|
|
121
|
+
|
|
231
122
|
const args = {
|
|
232
|
-
|
|
123
|
+
appDir,
|
|
233
124
|
cacheDir,
|
|
234
|
-
pluginsPath,
|
|
235
125
|
dest,
|
|
126
|
+
entry,
|
|
236
127
|
env,
|
|
237
|
-
port,
|
|
238
128
|
options,
|
|
129
|
+
pluginsPath,
|
|
239
130
|
roots,
|
|
240
131
|
devServer: {
|
|
241
132
|
port,
|
|
@@ -246,7 +137,6 @@ async function watchAdmin({ plugins, dir, host, port, browser, options }) {
|
|
|
246
137
|
warnings: false,
|
|
247
138
|
},
|
|
248
139
|
},
|
|
249
|
-
|
|
250
140
|
open: browser === 'true' ? true : browser,
|
|
251
141
|
devMiddleware: {
|
|
252
142
|
publicPath: options.adminPath,
|
|
@@ -256,9 +146,10 @@ async function watchAdmin({ plugins, dir, host, port, browser, options }) {
|
|
|
256
146
|
disableDotRule: true,
|
|
257
147
|
},
|
|
258
148
|
},
|
|
149
|
+
tsConfigFilePath,
|
|
259
150
|
};
|
|
260
151
|
|
|
261
|
-
const webpackConfig = getCustomWebpackConfig(
|
|
152
|
+
const webpackConfig = getCustomWebpackConfig(appDir, args);
|
|
262
153
|
|
|
263
154
|
const compiler = webpack(webpackConfig);
|
|
264
155
|
|
|
@@ -279,90 +170,7 @@ async function watchAdmin({ plugins, dir, host, port, browser, options }) {
|
|
|
279
170
|
|
|
280
171
|
runServer();
|
|
281
172
|
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Listen to files change and copy the changed files in the .cache/admin folder
|
|
287
|
-
* when using the dev mode
|
|
288
|
-
* @param {string} dir
|
|
289
|
-
*/
|
|
290
|
-
async function watchFiles(dir) {
|
|
291
|
-
const cacheDir = path.join(dir, '.cache');
|
|
292
|
-
const appExtensionFile = path.join(dir, 'src', 'admin', 'app.js');
|
|
293
|
-
const extensionsPath = path.join(dir, 'src', 'admin', 'extensions');
|
|
294
|
-
|
|
295
|
-
// Only watch the admin/app.js file and the files that are in the ./admin/extensions/folder
|
|
296
|
-
const filesToWatch = [appExtensionFile, extensionsPath];
|
|
297
|
-
|
|
298
|
-
const watcher = chokidar.watch(filesToWatch, {
|
|
299
|
-
ignoreInitial: true,
|
|
300
|
-
ignorePermissionErrors: true,
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
watcher.on('all', async (event, filePath) => {
|
|
304
|
-
const isAppFile = filePath.includes(appExtensionFile);
|
|
305
|
-
|
|
306
|
-
// The app.js file needs to be copied in the .cache/admin/src/app.js and the other ones needs to
|
|
307
|
-
// be copied in the .cache/admin/src/extensions folder
|
|
308
|
-
const targetPath = isAppFile
|
|
309
|
-
? path.join(path.normalize(filePath.split(appExtensionFile)[1]), 'app.js')
|
|
310
|
-
: path.join('extensions', path.normalize(filePath.split(extensionsPath)[1]));
|
|
311
|
-
|
|
312
|
-
const destFolder = path.join(cacheDir, 'admin', 'src');
|
|
313
|
-
|
|
314
|
-
if (event === 'unlink' || event === 'unlinkDir') {
|
|
315
|
-
// Remove the file or folder
|
|
316
|
-
// We need to copy the original files when deleting an override one
|
|
317
|
-
try {
|
|
318
|
-
fs.removeSync(path.join(destFolder, targetPath));
|
|
319
|
-
} catch (err) {
|
|
320
|
-
console.log('An error occured while deleting the file', err);
|
|
321
|
-
}
|
|
322
|
-
} else {
|
|
323
|
-
// In any other case just copy the file into the .cache/admin/src folder
|
|
324
|
-
try {
|
|
325
|
-
await fs.copy(filePath, path.join(destFolder, targetPath));
|
|
326
|
-
} catch (err) {
|
|
327
|
-
console.log(err);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
const hasCustomAdminCode = async dir => {
|
|
334
|
-
const customAdminPath = path.join(dir, 'src', 'admin');
|
|
335
|
-
const customAdminConfigFile = path.join(customAdminPath, 'app.js');
|
|
336
|
-
const customAdminWebpackFile = path.join(customAdminPath, 'webpack.config.js');
|
|
337
|
-
|
|
338
|
-
const hasCustomConfigFile = await fs.pathExists(customAdminConfigFile);
|
|
339
|
-
const hasCustomWebpackFile = await fs.pathExists(customAdminWebpackFile);
|
|
340
|
-
|
|
341
|
-
return hasCustomConfigFile || hasCustomWebpackFile;
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Checks if the project's installed plugins are not the same as a default one.
|
|
346
|
-
* @param {Object} plugins
|
|
347
|
-
* @returns {boolean}
|
|
348
|
-
*/
|
|
349
|
-
const hasNonDefaultPlugins = plugins => {
|
|
350
|
-
// List of plugins that are not the ones installed in a generated app
|
|
351
|
-
const installedPlugins = Object.keys(plugins).filter(x => !DEFAULT_PLUGINS.includes(x));
|
|
352
|
-
|
|
353
|
-
// List of default plugins uninstalled from a generated app
|
|
354
|
-
const missingPlugins = DEFAULT_PLUGINS.filter(x => !Object.keys(plugins).includes(x));
|
|
355
|
-
|
|
356
|
-
const diff = [...installedPlugins, ...missingPlugins];
|
|
357
|
-
|
|
358
|
-
return diff.length > 0;
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
async function shouldBuildAdmin({ dir, plugins }) {
|
|
362
|
-
const appHasCustomAdminCode = await hasCustomAdminCode(dir);
|
|
363
|
-
const appHasNonDefaultPlugins = hasNonDefaultPlugins(plugins);
|
|
364
|
-
|
|
365
|
-
return appHasCustomAdminCode || appHasNonDefaultPlugins;
|
|
173
|
+
watchAdminFiles(appDir, useTypeScript);
|
|
366
174
|
}
|
|
367
175
|
|
|
368
176
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/admin",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0-beta.1",
|
|
4
4
|
"description": "Strapi Admin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"develop:webpack": "cross-env NODE_ENV=development webpack serve --config webpack.config.dev.js --progress profile",
|
|
29
29
|
"prepublishOnly": "yarn build",
|
|
30
30
|
"build": "rimraf build && node ./scripts/build.js",
|
|
31
|
+
"build:mesure": "rimraf build && cross-env MESURE_BUILD_SPEED=true node ./scripts/build.js",
|
|
31
32
|
"test": "echo \"no tests yet\"",
|
|
32
33
|
"test:unit": "jest --verbose",
|
|
33
34
|
"test:front": "cross-env IS_EE=true jest --config ./jest.config.front.js",
|
|
@@ -49,11 +50,12 @@
|
|
|
49
50
|
"@fortawesome/free-brands-svg-icons": "^5.15.3",
|
|
50
51
|
"@fortawesome/free-solid-svg-icons": "^5.15.3",
|
|
51
52
|
"@fortawesome/react-fontawesome": "^0.1.14",
|
|
52
|
-
"@strapi/babel-plugin-switch-ee-ce": "4.
|
|
53
|
+
"@strapi/babel-plugin-switch-ee-ce": "4.3.0-beta.1",
|
|
53
54
|
"@strapi/design-system": "1.1.1",
|
|
54
|
-
"@strapi/helper-plugin": "4.
|
|
55
|
+
"@strapi/helper-plugin": "4.3.0-beta.1",
|
|
55
56
|
"@strapi/icons": "1.1.1",
|
|
56
|
-
"@strapi/utils": "4.
|
|
57
|
+
"@strapi/typescript-utils": "4.3.0-beta.1",
|
|
58
|
+
"@strapi/utils": "4.3.0-beta.1",
|
|
57
59
|
"axios": "0.24.0",
|
|
58
60
|
"babel-loader": "8.2.3",
|
|
59
61
|
"babel-plugin-styled-components": "2.0.2",
|
|
@@ -69,6 +71,7 @@
|
|
|
69
71
|
"execa": "^1.0.0",
|
|
70
72
|
"fast-deep-equal": "3.1.3",
|
|
71
73
|
"font-awesome": "^4.7.0",
|
|
74
|
+
"fork-ts-checker-webpack-plugin": "7.2.1",
|
|
72
75
|
"formik": "^2.2.6",
|
|
73
76
|
"fs-extra": "10.0.0",
|
|
74
77
|
"highlight.js": "^10.4.1",
|
|
@@ -134,11 +137,13 @@
|
|
|
134
137
|
},
|
|
135
138
|
"devDependencies": {
|
|
136
139
|
"duplicate-dependencies-webpack-plugin": "0.2.0",
|
|
140
|
+
"glob": "8.0.3",
|
|
141
|
+
"speed-measure-webpack-plugin": "1.5.0",
|
|
137
142
|
"webpack-bundle-analyzer": "4.4.1"
|
|
138
143
|
},
|
|
139
144
|
"engines": {
|
|
140
145
|
"node": ">=14.19.1 <=16.x.x",
|
|
141
146
|
"npm": ">=6.0.0"
|
|
142
147
|
},
|
|
143
|
-
"gitHead": "
|
|
148
|
+
"gitHead": "9d6555398960c39159d66bb4eea3bcb0362e37e3"
|
|
144
149
|
}
|
package/scripts/build.js
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const webpack = require('webpack');
|
|
5
5
|
const { isObject } = require('lodash');
|
|
6
|
+
// eslint-disable-next-line node/no-extraneous-require
|
|
7
|
+
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
|
|
8
|
+
|
|
6
9
|
const webpackConfig = require('../webpack.config');
|
|
10
|
+
const getPluginsPath = require('../utils/get-plugins-path');
|
|
7
11
|
const {
|
|
8
12
|
getCorePluginsPath,
|
|
9
13
|
getPluginToInstallPath,
|
|
@@ -12,29 +16,41 @@ const {
|
|
|
12
16
|
|
|
13
17
|
const PLUGINS_TO_INSTALL = ['i18n', 'users-permissions'];
|
|
14
18
|
|
|
19
|
+
// Wrapper that outputs the webpack speed
|
|
20
|
+
const smp = new SpeedMeasurePlugin();
|
|
21
|
+
|
|
15
22
|
const buildAdmin = async () => {
|
|
16
23
|
const entry = path.join(__dirname, '..', 'admin', 'src');
|
|
17
24
|
const dest = path.join(__dirname, '..', 'build');
|
|
25
|
+
const tsConfigFilePath = path.join(__dirname, '..', 'admin', 'src', 'tsconfig.json');
|
|
26
|
+
|
|
18
27
|
const corePlugins = getCorePluginsPath();
|
|
19
28
|
const plugins = getPluginToInstallPath(PLUGINS_TO_INSTALL);
|
|
20
29
|
const allPlugins = { ...corePlugins, ...plugins };
|
|
30
|
+
const pluginsPath = getPluginsPath();
|
|
21
31
|
|
|
22
32
|
await createPluginsFile(allPlugins);
|
|
23
33
|
|
|
24
34
|
const args = {
|
|
25
35
|
entry,
|
|
26
36
|
dest,
|
|
27
|
-
cacheDir: path.
|
|
28
|
-
pluginsPath
|
|
37
|
+
cacheDir: path.join(__dirname, '..'),
|
|
38
|
+
pluginsPath,
|
|
29
39
|
env: 'production',
|
|
30
40
|
optimize: true,
|
|
31
41
|
options: {
|
|
32
42
|
backend: 'http://localhost:1337',
|
|
33
43
|
adminPath: '/admin/',
|
|
34
44
|
},
|
|
45
|
+
tsConfigFilePath,
|
|
35
46
|
};
|
|
36
47
|
|
|
37
|
-
const
|
|
48
|
+
const config =
|
|
49
|
+
process.env.MEASURE_BUILD_SPEED === 'true'
|
|
50
|
+
? smp.wrap(webpackConfig(args))
|
|
51
|
+
: webpackConfig(args);
|
|
52
|
+
|
|
53
|
+
const compiler = webpack(config);
|
|
38
54
|
|
|
39
55
|
console.log('Building the admin panel');
|
|
40
56
|
|
|
@@ -5,6 +5,7 @@ const execa = require('execa');
|
|
|
5
5
|
const _ = require('lodash');
|
|
6
6
|
const { exists } = require('fs-extra');
|
|
7
7
|
const { ValidationError } = require('@strapi/utils').errors;
|
|
8
|
+
const { isUsingTypeScript } = require('@strapi/typescript-utils');
|
|
8
9
|
// eslint-disable-next-line node/no-extraneous-require
|
|
9
10
|
const ee = require('@strapi/strapi/lib/utils/ee');
|
|
10
11
|
|
|
@@ -81,6 +82,26 @@ module.exports = {
|
|
|
81
82
|
return projectSettingsService.updateProjectSettings({ ...body, ...formatedFiles });
|
|
82
83
|
},
|
|
83
84
|
|
|
85
|
+
async telemetryProperties(ctx) {
|
|
86
|
+
// If the telemetry is disabled, ignore the request and return early
|
|
87
|
+
if (strapi.telemetry.isDisabled) {
|
|
88
|
+
ctx.status = 204;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const useTypescriptOnServer = await isUsingTypeScript(strapi.dirs.app.root);
|
|
93
|
+
const useTypescriptOnAdmin = await isUsingTypeScript(
|
|
94
|
+
path.join(strapi.dirs.app.root, 'src', 'admin')
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
data: {
|
|
99
|
+
useTypescriptOnServer,
|
|
100
|
+
useTypescriptOnAdmin,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
|
|
84
105
|
async information() {
|
|
85
106
|
const currentEnvironment = strapi.config.get('environment');
|
|
86
107
|
const autoReload = strapi.config.get('autoReload', false);
|
package/server/policies/index.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createPolicy } = require('@strapi/utils').policy;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This policy is used for routes dealing with telemetry and analytics content.
|
|
7
|
+
* It will fails when the telemetry has been disabled on the server.
|
|
8
|
+
*/
|
|
9
|
+
module.exports = createPolicy({
|
|
10
|
+
name: 'admin::isTelemetryEnabled',
|
|
11
|
+
handler(_ctx, _config, { strapi }) {
|
|
12
|
+
if (strapi.telemetry.isDisabled) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
});
|
package/server/routes/admin.js
CHANGED
|
@@ -49,6 +49,14 @@ module.exports = [
|
|
|
49
49
|
policies: ['admin::isAuthenticatedAdmin'],
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
|
+
{
|
|
53
|
+
method: 'GET',
|
|
54
|
+
path: '/telemetry-properties',
|
|
55
|
+
handler: 'admin.telemetryProperties',
|
|
56
|
+
config: {
|
|
57
|
+
auth: false,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
52
60
|
{
|
|
53
61
|
method: 'GET',
|
|
54
62
|
path: '/plugins',
|
|
@@ -5,7 +5,7 @@ const fse = require('fs-extra');
|
|
|
5
5
|
const koaStatic = require('koa-static');
|
|
6
6
|
|
|
7
7
|
const registerAdminPanelRoute = ({ strapi }) => {
|
|
8
|
-
let buildDir = resolve(strapi.dirs.root, 'build');
|
|
8
|
+
let buildDir = resolve(strapi.dirs.dist.root, 'build');
|
|
9
9
|
|
|
10
10
|
if (!fse.pathExistsSync(buildDir)) {
|
|
11
11
|
buildDir = resolve(__dirname, '../../build');
|