@strapi/strapi 4.2.0-beta.3 → 4.2.1-alpha.0
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/bin/strapi.js +1 -2
- package/lib/Strapi.js +4 -42
- package/lib/commands/admin-create.js +1 -15
- package/lib/commands/admin-reset.js +1 -15
- package/lib/commands/build.js +44 -18
- package/lib/commands/configurationDump.js +1 -14
- package/lib/commands/configurationRestore.js +1 -16
- package/lib/commands/console.js +2 -16
- package/lib/commands/develop.js +74 -114
- package/lib/commands/routes/list.js +1 -15
- package/lib/commands/start.js +2 -12
- package/lib/commands/watchAdmin.js +10 -10
- package/lib/core/app-configuration/index.js +3 -4
- package/lib/core/app-configuration/load-config-file.js +1 -3
- package/lib/core/bootstrap.js +2 -2
- package/lib/core/loaders/apis.js +5 -6
- package/lib/core/loaders/components.js +4 -5
- package/lib/core/loaders/middlewares.js +3 -5
- package/lib/core/loaders/plugins/get-enabled-plugins.js +1 -2
- package/lib/core/loaders/plugins/get-user-plugins-config.js +2 -2
- package/lib/core/loaders/plugins/index.js +1 -1
- package/lib/core/loaders/policies.js +2 -4
- package/lib/core/loaders/src-index.js +4 -6
- package/lib/core/registries/policies.d.ts +1 -1
- package/lib/core-api/controller/index.d.ts +9 -14
- package/lib/core-api/service/index.d.ts +9 -10
- package/lib/factories.d.ts +18 -22
- package/lib/index.d.ts +6 -7
- package/lib/load/load-files.js +1 -3
- package/lib/middlewares/favicon.js +1 -1
- package/lib/middlewares/public/index.js +1 -2
- package/lib/services/fs.js +1 -1
- package/lib/services/metrics/index.js +1 -5
- package/lib/services/metrics/sender.js +0 -7
- package/lib/services/server/middleware.js +1 -1
- package/lib/utils/get-dirs.js +10 -24
- package/lib/utils/index.js +0 -2
- package/lib/utils/update-notifier/index.js +1 -1
- package/package.json +14 -16
- package/lib/commands/builders/admin.js +0 -59
- package/lib/commands/builders/index.js +0 -9
- package/lib/commands/builders/typescript.js +0 -32
- package/lib/types/strapi.d.ts +0 -291
- package/lib/types/utils.d.ts +0 -1
- package/lib/utils/import-default.js +0 -9
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { green } = require('chalk');
|
|
4
|
-
|
|
5
|
-
const strapiAdmin = require('@strapi/admin');
|
|
6
|
-
const { getConfigUrls } = require('@strapi/utils');
|
|
7
|
-
|
|
8
|
-
const ee = require('../../utils/ee');
|
|
9
|
-
const addSlash = require('../../utils/addSlash');
|
|
10
|
-
const strapi = require('../../index');
|
|
11
|
-
const getEnabledPlugins = require('../../core/loaders/plugins/get-enabled-plugins');
|
|
12
|
-
|
|
13
|
-
module.exports = async ({ buildDestDir, forceBuild = true, optimization, srcDir }) => {
|
|
14
|
-
const strapiInstance = strapi({
|
|
15
|
-
// Directories
|
|
16
|
-
appDir: srcDir,
|
|
17
|
-
distDir: buildDestDir,
|
|
18
|
-
// Options
|
|
19
|
-
autoReload: true,
|
|
20
|
-
serveAdminPanel: false,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const plugins = await getEnabledPlugins(strapiInstance);
|
|
24
|
-
|
|
25
|
-
const env = strapiInstance.config.get('environment');
|
|
26
|
-
const { serverUrl, adminPath } = getConfigUrls(strapiInstance.config, true);
|
|
27
|
-
|
|
28
|
-
console.log(`Building your admin UI with ${green(env)} configuration...`);
|
|
29
|
-
|
|
30
|
-
// Always remove the .cache and build folders
|
|
31
|
-
// FIXME the BE should remove the build dir and the admin should only
|
|
32
|
-
// be responsible of removing the .cache dir.
|
|
33
|
-
await strapiAdmin.clean({ appDir: srcDir, buildDestDir });
|
|
34
|
-
|
|
35
|
-
// @convly shouldn't we use the app dir here?
|
|
36
|
-
ee({ dir: buildDestDir });
|
|
37
|
-
|
|
38
|
-
return strapiAdmin
|
|
39
|
-
.build({
|
|
40
|
-
appDir: srcDir,
|
|
41
|
-
buildDestDir,
|
|
42
|
-
// front end build env is always production for now
|
|
43
|
-
env: 'production',
|
|
44
|
-
forceBuild,
|
|
45
|
-
plugins,
|
|
46
|
-
optimize: optimization,
|
|
47
|
-
options: {
|
|
48
|
-
backend: serverUrl,
|
|
49
|
-
adminPath: addSlash(adminPath),
|
|
50
|
-
},
|
|
51
|
-
})
|
|
52
|
-
.then(() => {
|
|
53
|
-
console.log('Admin UI built successfully');
|
|
54
|
-
})
|
|
55
|
-
.catch(err => {
|
|
56
|
-
console.error(err);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
});
|
|
59
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs-extra');
|
|
5
|
-
const tsUtils = require('@strapi/typescript-utils');
|
|
6
|
-
|
|
7
|
-
const cleanupDistDirectory = async distDir => {
|
|
8
|
-
if (!(await fs.pathExists(distDir))) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const dirContent = await fs.readdir(distDir);
|
|
13
|
-
const validFilenames = dirContent
|
|
14
|
-
// Ignore the admin build folder
|
|
15
|
-
.filter(filename => filename !== 'build');
|
|
16
|
-
|
|
17
|
-
for (const filename of validFilenames) {
|
|
18
|
-
await fs.remove(path.resolve(distDir, filename));
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
module.exports = async ({ srcDir, distDir, watch = false }) => {
|
|
23
|
-
const isTSProject = await tsUtils.isUsingTypeScript(srcDir);
|
|
24
|
-
|
|
25
|
-
if (!isTSProject) {
|
|
26
|
-
throw new Error(`tsconfig file not found in ${srcDir}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
await cleanupDistDirectory(distDir);
|
|
30
|
-
|
|
31
|
-
return tsUtils.compile(srcDir, { watch });
|
|
32
|
-
};
|
package/lib/types/strapi.d.ts
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import type Koa from 'koa';
|
|
2
|
-
|
|
3
|
-
import type { StringMap } from './utils';
|
|
4
|
-
|
|
5
|
-
type Controller = {
|
|
6
|
-
[methodName: string | number | symbol]: (context: Koa.Context) => unknown;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The Strapi interface implemented by the main Strapi class.
|
|
11
|
-
*/
|
|
12
|
-
export interface Strapi {
|
|
13
|
-
/**
|
|
14
|
-
* Getter for the Strapi enterprise edition configuration
|
|
15
|
-
*/
|
|
16
|
-
readonly EE: any;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Getter for the Strapi configuration container
|
|
20
|
-
*/
|
|
21
|
-
readonly config: any;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Getter for the Strapi auth container
|
|
25
|
-
*/
|
|
26
|
-
readonly auth: any;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Getter for the Strapi sanitizers container
|
|
30
|
-
*/
|
|
31
|
-
readonly sanitizers: any;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Getter for the Strapi services container
|
|
35
|
-
*
|
|
36
|
-
* It returns all the registered services
|
|
37
|
-
*/
|
|
38
|
-
readonly services: StringMap<Service>;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Find a service using its unique identifier
|
|
42
|
-
*/
|
|
43
|
-
service<T extends Service = unknown>(uid: string): T | undefined;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Getter for the Strapi controllers container
|
|
47
|
-
*
|
|
48
|
-
* It returns all the registered controllers
|
|
49
|
-
*/
|
|
50
|
-
readonly controllers: StringMap<Controller>;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Find a controller using its unique identifier
|
|
54
|
-
*/
|
|
55
|
-
controller(uid: string): Controller | undefined;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Getter for the Strapi content types container
|
|
59
|
-
*
|
|
60
|
-
* It returns all the registered content types
|
|
61
|
-
*/
|
|
62
|
-
readonly contentTypes: any;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Find a content type using its unique identifier
|
|
66
|
-
*/
|
|
67
|
-
contentType(uid: string): any;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Getter for the Strapi policies container
|
|
71
|
-
*
|
|
72
|
-
* It returns all the registered policies
|
|
73
|
-
*/
|
|
74
|
-
readonly policies: any;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Find a policy using its name
|
|
78
|
-
*/
|
|
79
|
-
policy(name: string): any;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Getter for the Strapi middlewares container
|
|
83
|
-
*
|
|
84
|
-
* It returns all the registered middlewares
|
|
85
|
-
*/
|
|
86
|
-
readonly middlewares: any;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Find a middleware using its name
|
|
90
|
-
*/
|
|
91
|
-
middleware(): any;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Getter for the Strapi plugins container
|
|
95
|
-
*
|
|
96
|
-
* It returns all the registered plugins
|
|
97
|
-
*/
|
|
98
|
-
readonly plugins: any;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Find a plugin using its name
|
|
102
|
-
*/
|
|
103
|
-
plugin(name: string): any;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Getter for the Strapi hooks container
|
|
107
|
-
*
|
|
108
|
-
* It returns all the registered hooks
|
|
109
|
-
*/
|
|
110
|
-
readonly hooks: any;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Find a hook using its name
|
|
114
|
-
*/
|
|
115
|
-
hook(): any;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Getter for the Strapi APIs container
|
|
119
|
-
*
|
|
120
|
-
* It returns all the registered APIs
|
|
121
|
-
*/
|
|
122
|
-
readonly api: any;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Strapi Register Lifecycle.
|
|
126
|
-
*
|
|
127
|
-
* - Load
|
|
128
|
-
* - The user application
|
|
129
|
-
* - The plugins
|
|
130
|
-
* - The admin
|
|
131
|
-
* - The APIs
|
|
132
|
-
* - The components
|
|
133
|
-
* - The middlewares
|
|
134
|
-
* - The policies
|
|
135
|
-
* - Trigger Strapi internal bootstrap
|
|
136
|
-
* - Create the webhooks runner
|
|
137
|
-
* - Create the internal hooks registry.
|
|
138
|
-
* - Init the telemetry cron job and middleware
|
|
139
|
-
* - Run all the `register` lifecycle methods loaded by the user application or the enabled plugins
|
|
140
|
-
*/
|
|
141
|
-
register(): Promise<Strapi>;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Bootstraping phase.
|
|
145
|
-
*
|
|
146
|
-
* - Load all the content types
|
|
147
|
-
* - Initialize the database layer
|
|
148
|
-
* - Initialize the entity service
|
|
149
|
-
* - Run the schemas/database synchronization
|
|
150
|
-
* - Start the webhooks and initializing middlewares and routes
|
|
151
|
-
* - Run all the `bootstrap` lifecycle methods loaded by the
|
|
152
|
-
* user application or the enabled plugins
|
|
153
|
-
*/
|
|
154
|
-
bootstrap(): Promise<Strapi>;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Destroy phase
|
|
158
|
-
*
|
|
159
|
-
* - Destroy Strapi server
|
|
160
|
-
* - Run all the `destroy` lifecycle methods loaded by the
|
|
161
|
-
* user application or the enabled plugins
|
|
162
|
-
* - Cleanup the event hub
|
|
163
|
-
* - Gracefully stop the database
|
|
164
|
-
* - Stop the telemetry and cron instance
|
|
165
|
-
* - Cleanup the global scope by removing global.strapi
|
|
166
|
-
*/
|
|
167
|
-
destroy(): Promise<void>;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Run all functions registered for a given lifecycle. (Strapi core, user app, plugins)
|
|
171
|
-
*/
|
|
172
|
-
runLifecyclesFunctions<T extends Lifecycles[keyof Lifecycles]>(lifecycleName: T): Promise<void>;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Load the application if needed and start the server
|
|
176
|
-
*/
|
|
177
|
-
start(): Promise<void>;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Stop the server and provide a custom error and message
|
|
181
|
-
*/
|
|
182
|
-
stopWithError<TError = unknown>(error: TError, customMessage?: string): void;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Gracefully stop the server
|
|
186
|
-
* Call the destroy method.
|
|
187
|
-
*/
|
|
188
|
-
stop(code?: number): void;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Load the server and the user application.
|
|
192
|
-
* It basically triggers the register and bootstrap phases
|
|
193
|
-
*/
|
|
194
|
-
load(): Promise<Strapi>;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Restart the server and reload all the configuration.
|
|
198
|
-
* It re-runs all the lifecycles phases.
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ``` ts
|
|
202
|
-
* setImmediate(() => strapi.reload());
|
|
203
|
-
* ```
|
|
204
|
-
*/
|
|
205
|
-
reload(): () => void;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Initialize and start all the webhooks registered in the webhook store
|
|
209
|
-
*/
|
|
210
|
-
startWebhooks(): Promise<void>;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Method called when the server is fully initialized and listen to incomming requests.
|
|
214
|
-
* It handles tasks such as logging the startup message
|
|
215
|
-
* or automatically opening the administration panel.
|
|
216
|
-
*/
|
|
217
|
-
postListen(): Promise<void>;
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Start listening for incomming requests
|
|
221
|
-
*/
|
|
222
|
-
listen(): Promise<void | Error>;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Opent he administration panel in a browser if the option is enabled.
|
|
226
|
-
* You can disable it using the admin.autoOpen configuration variable.
|
|
227
|
-
*
|
|
228
|
-
* Note: It only works in development envs.
|
|
229
|
-
*/
|
|
230
|
-
openAdmin(options: { isInitialized: boolean }): Promise<void>;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Load the admin panel server logic into the server code and initialize its configuration.
|
|
234
|
-
*/
|
|
235
|
-
loadAdmin(): Promise<void>;
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Resolve every enabled plugin and load them into the application.
|
|
239
|
-
*/
|
|
240
|
-
loadPlugins(): Promise<void>;
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Load every global policies in the policies container by
|
|
244
|
-
* reading from the `strapi.dirs.dist.policies` directory.
|
|
245
|
-
*/
|
|
246
|
-
loadPolicies(): Promise<void>;
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Load every APIs and their components (config, routes, controllers, services,
|
|
250
|
-
* policies, middlewares, content-types) in the API container.
|
|
251
|
-
*/
|
|
252
|
-
loadAPIs(): Promise<void>;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Resolve every components in the user application and store them in `strapi.components`
|
|
256
|
-
*/
|
|
257
|
-
loadComponents(): Promise<void>;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Load every global and core middlewares in the middlewares container by
|
|
261
|
-
* reading from the `strapi.dirs.dist.middlewares` and internal middlewares directory.
|
|
262
|
-
*/
|
|
263
|
-
loadMiddlewares(): Promise<void>;
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Load the user application in the server by reading the `src/index.js` file.
|
|
267
|
-
*/
|
|
268
|
-
loadApp(): Promise<void>;
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Add internal hooks to the hooks container.
|
|
272
|
-
* Those hooks are meant for internal usage and might break in future releases.
|
|
273
|
-
*/
|
|
274
|
-
registerInternalHooks(): void;
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Find a model (content-type, component) based on its unique identifier.
|
|
278
|
-
*/
|
|
279
|
-
getModel(uid: string): any;
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Binds database queries for a specific model based on its unique identifier.
|
|
283
|
-
*/
|
|
284
|
-
query(uid: string): any;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export interface Lifecycles {
|
|
288
|
-
REGISTER: 'register';
|
|
289
|
-
BOOTSTRAP: 'bootstrap';
|
|
290
|
-
DESTROY: 'destroy';
|
|
291
|
-
}
|
package/lib/types/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type StringMap<T> = { [key: string]: T };
|