Skip to content

Commit

Permalink
Merge branch 'main' of github.com:strapi/strapi into features/upgrade…
Browse files Browse the repository at this point in the history
…-tool
  • Loading branch information
Convly committed Dec 6, 2023
2 parents ea34d03 + 8e2421b commit 133b68e
Show file tree
Hide file tree
Showing 74 changed files with 1,172 additions and 549 deletions.
2 changes: 1 addition & 1 deletion .github/actions/check-pr-status/package.json
@@ -1,6 +1,6 @@
{
"name": "check-pr-status",
"version": "4.15.4",
"version": "4.15.5",
"private": true,
"license": "MIT",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/changeFreeze.yml
Expand Up @@ -8,7 +8,7 @@ permissions: read-all

jobs:
check-ownership:
name: "Check if PR was created by a Strapi Team Member"
name: 'Check if PR was created by a Strapi Team Member'
runs-on: ubuntu-latest
outputs:
isTeamMember: ${{ steps.get-user-teams-membership.outputs.isTeamMember }}
Expand All @@ -20,7 +20,7 @@ jobs:
team: team
username: ${{ github.actor }}
send-response:
name: "Alert user to change freeze"
name: 'Alert user to change freeze'
runs-on: ubuntu-latest
permissions:
pull-requests: write
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc.yml
@@ -1,6 +1,6 @@
compressionLevel: mixed

defaultSemverRangePrefix: ""
defaultSemverRangePrefix: ''

enableGlobalCache: true

Expand Down
2 changes: 1 addition & 1 deletion examples/getstarted/config/middlewares.js
Expand Up @@ -3,11 +3,11 @@
const responseHandlers = require('./src/response-handlers');

module.exports = [
'strapi::logger',
'strapi::errors',
'strapi::security',
'strapi::cors',
'strapi::poweredBy',
'strapi::logger',
'strapi::query',
'strapi::body',
'strapi::session',
Expand Down
1 change: 1 addition & 0 deletions examples/getstarted/jsconfig.json
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"jsx": "react",
"moduleResolution": "nodenext",
"target": "ES2021",
"checkJs": true,
Expand Down
22 changes: 11 additions & 11 deletions examples/getstarted/package.json
@@ -1,6 +1,6 @@
{
"name": "getstarted",
"version": "4.15.4",
"version": "4.15.5",
"private": true,
"description": "A Strapi application.",
"license": "SEE LICENSE IN LICENSE",
Expand All @@ -14,16 +14,16 @@
},
"dependencies": {
"@strapi/icons": "1.11.0",
"@strapi/plugin-color-picker": "4.15.4",
"@strapi/plugin-documentation": "4.15.4",
"@strapi/plugin-graphql": "4.15.4",
"@strapi/plugin-i18n": "4.15.4",
"@strapi/plugin-sentry": "4.15.4",
"@strapi/plugin-users-permissions": "4.15.4",
"@strapi/provider-email-mailgun": "4.15.4",
"@strapi/provider-upload-aws-s3": "4.15.4",
"@strapi/provider-upload-cloudinary": "4.15.4",
"@strapi/strapi": "4.15.4",
"@strapi/plugin-color-picker": "4.15.5",
"@strapi/plugin-documentation": "4.15.5",
"@strapi/plugin-graphql": "4.15.5",
"@strapi/plugin-i18n": "4.15.5",
"@strapi/plugin-sentry": "4.15.5",
"@strapi/plugin-users-permissions": "4.15.5",
"@strapi/provider-email-mailgun": "4.15.5",
"@strapi/provider-upload-aws-s3": "4.15.5",
"@strapi/provider-upload-cloudinary": "4.15.5",
"@strapi/strapi": "4.15.5",
"better-sqlite3": "8.6.0",
"lodash": "4.17.21",
"mysql": "2.18.1",
Expand Down
12 changes: 11 additions & 1 deletion examples/getstarted/src/admin/app.js
@@ -1,8 +1,18 @@
import React from 'react';
import { Button } from '@strapi/design-system';

const config = {
locales: ['it', 'es', 'en'],
};
const bootstrap = () => {
const bootstrap = (app) => {
console.log('I AM BOOTSTRAPPED');

app.injectContentManagerComponent('editView', 'right-links', {
name: 'PreviewButton',
Component: () => (
<Button onClick={() => window.alert('Not here, The preview is.')}>Preview</Button>
),
});
};

export default {
Expand Down
2 changes: 1 addition & 1 deletion examples/kitchensink-ts/config/middlewares.ts
@@ -1,9 +1,9 @@
export default [
'strapi::logger',
'strapi::errors',
'strapi::security',
'strapi::cors',
'strapi::poweredBy',
'strapi::logger',
'strapi::query',
'strapi::body',
'strapi::session',
Expand Down
8 changes: 4 additions & 4 deletions examples/kitchensink-ts/package.json
@@ -1,6 +1,6 @@
{
"name": "kitchensink-ts",
"version": "4.15.4",
"version": "4.15.5",
"private": true,
"description": "A Strapi application",
"license": "MIT",
Expand All @@ -14,9 +14,9 @@
"strapi": "strapi"
},
"dependencies": {
"@strapi/plugin-i18n": "4.15.4",
"@strapi/plugin-users-permissions": "4.15.4",
"@strapi/strapi": "4.15.4",
"@strapi/plugin-i18n": "4.15.5",
"@strapi/plugin-users-permissions": "4.15.5",
"@strapi/strapi": "4.15.5",
"better-sqlite3": "8.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
10 changes: 5 additions & 5 deletions examples/kitchensink/package.json
@@ -1,6 +1,6 @@
{
"name": "kitchensink",
"version": "4.15.4",
"version": "4.15.5",
"private": true,
"description": "A Strapi application.",
"license": "SEE LICENSE IN LICENSE",
Expand All @@ -13,10 +13,10 @@
"strapi": "strapi"
},
"dependencies": {
"@strapi/provider-email-mailgun": "4.15.4",
"@strapi/provider-upload-aws-s3": "4.15.4",
"@strapi/provider-upload-cloudinary": "4.15.4",
"@strapi/strapi": "4.15.4",
"@strapi/provider-email-mailgun": "4.15.5",
"@strapi/provider-upload-aws-s3": "4.15.5",
"@strapi/provider-upload-cloudinary": "4.15.5",
"@strapi/strapi": "4.15.5",
"lodash": "4.17.21",
"mysql": "2.18.1",
"mysql2": "3.6.0",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
@@ -1,5 +1,5 @@
{
"version": "4.15.4",
"version": "4.15.5",
"packages": ["packages/*", "examples/*"],
"npmClient": "yarn",
"useWorkspaces": true,
Expand Down
6 changes: 3 additions & 3 deletions packages/admin-test-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@strapi/admin-test-utils",
"version": "4.15.4",
"version": "4.15.5",
"private": true,
"description": "Test utilities for the Strapi administration panel",
"license": "MIT",
Expand Down Expand Up @@ -75,8 +75,8 @@
"@reduxjs/toolkit": "1.9.7",
"@strapi/pack-up": "workspace:*",
"@testing-library/jest-dom": "5.16.5",
"eslint-config-custom": "4.15.4",
"tsconfig": "4.15.4"
"eslint-config-custom": "4.15.5",
"tsconfig": "4.15.5"
},
"peerDependencies": {
"@reduxjs/toolkit": "^1.9.7",
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/create-strapi-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-strapi-app",
"version": "4.15.4",
"version": "4.15.5",
"description": "Generate a new Strapi application.",
"keywords": [
"create-strapi-app",
Expand Down Expand Up @@ -44,14 +44,14 @@
"watch": "pack-up watch"
},
"dependencies": {
"@strapi/generate-new": "4.15.4",
"@strapi/generate-new": "4.15.5",
"commander": "8.3.0",
"inquirer": "8.2.5"
},
"devDependencies": {
"@strapi/pack-up": "4.15.4",
"eslint-config-custom": "4.15.4",
"tsconfig": "4.15.4"
"@strapi/pack-up": "4.15.5",
"eslint-config-custom": "4.15.5",
"tsconfig": "4.15.5"
},
"engines": {
"node": ">=18.0.0 <=20.x.x",
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/create-strapi-starter/package.json
@@ -1,6 +1,6 @@
{
"name": "create-strapi-starter",
"version": "4.15.4",
"version": "4.15.5",
"description": "Generate a new Strapi application.",
"keywords": [
"create-strapi-starter",
Expand Down Expand Up @@ -44,7 +44,7 @@
"watch": "pack-up watch"
},
"dependencies": {
"@strapi/generate-new": "4.15.4",
"@strapi/generate-new": "4.15.5",
"chalk": "4.1.2",
"ci-info": "3.8.0",
"commander": "8.3.0",
Expand All @@ -54,9 +54,9 @@
"ora": "5.4.1"
},
"devDependencies": {
"@strapi/pack-up": "4.15.4",
"eslint-config-custom": "4.15.4",
"tsconfig": "4.15.4"
"@strapi/pack-up": "4.15.5",
"eslint-config-custom": "4.15.5",
"tsconfig": "4.15.5"
},
"engines": {
"node": ">=18.0.0 <=20.x.x",
Expand Down
16 changes: 7 additions & 9 deletions packages/core/admin/_internal/node/build.ts
@@ -1,13 +1,11 @@
import type { CLIContext } from '@strapi/strapi';
import EE from '@strapi/strapi/dist/utils/ee';
import * as tsUtils from '@strapi/typescript-utils';
import { checkRequiredDependencies } from './core/dependencies';
import { getTimer, prettyTime } from './core/timer';
import { createBuildContext } from './createBuildContext';
import { writeStaticClientFiles } from './staticFiles';
import { build as buildWebpack } from './webpack/build';
import { createBuildContext } from './createBuildContext';

import EE from '@strapi/strapi/dist/utils/ee';
import { getTimer } from './core/timer';

import type { CLIContext } from '@strapi/strapi';

interface BuildOptions extends CLIContext {
/**
Expand Down Expand Up @@ -56,7 +54,7 @@ const build = async ({ logger, cwd, tsconfig, ignorePrompts, ...options }: Build
tsUtils.compile(cwd, { configOptions: { ignoreDiagnostics: false } });

const compilingDuration = timer.end('compilingTS');
compilingTsSpinner.text = `Compiling TS (${compilingDuration}ms)`;
compilingTsSpinner.text = `Compiling TS (${prettyTime(compilingDuration)})`;
compilingTsSpinner.succeed();
}

Expand All @@ -71,7 +69,7 @@ const build = async ({ logger, cwd, tsconfig, ignorePrompts, ...options }: Build
options,
});
const contextDuration = timer.end('createBuildContext');
contextSpinner.text = `Building build context (${contextDuration}ms)`;
contextSpinner.text = `Building build context (${prettyTime(contextDuration)})`;
contextSpinner.succeed();

timer.start('buildAdmin');
Expand All @@ -85,7 +83,7 @@ const build = async ({ logger, cwd, tsconfig, ignorePrompts, ...options }: Build
await buildWebpack(ctx);

const buildDuration = timer.end('buildAdmin');
buildingSpinner.text = `Building admin panel (${buildDuration}ms)`;
buildingSpinner.text = `Building admin panel (${prettyTime(buildDuration)})`;
buildingSpinner.succeed();
} catch (err) {
buildingSpinner.fail();
Expand Down
24 changes: 18 additions & 6 deletions packages/core/admin/_internal/node/core/admin-customisations.ts
@@ -1,5 +1,6 @@
import path from 'node:path';
import { loadFile } from './files';
import { convertSystemPathToModulePath, pathExists } from '../core/files';
import { BuildContext } from '../createBuildContext';

const ADMIN_APP_FILES = ['app.js', 'app.mjs', 'app.ts', 'app.jsx', 'app.tsx'];

Expand All @@ -11,17 +12,28 @@ interface AdminCustomisations {
}

interface AppFile {
/**
* The system path to the file
*/
path: string;
config: AdminCustomisations['config'];
/**
* The module path to the file i.e. how you would import it
*/
modulePath: string;
}

const loadUserAppFile = async (appDir: string): Promise<AppFile | undefined> => {
const loadUserAppFile = async ({
runtimeDir,
appDir,
}: Pick<BuildContext, 'appDir' | 'runtimeDir'>): Promise<AppFile | undefined> => {
for (const file of ADMIN_APP_FILES) {
const filePath = path.join(appDir, 'src', 'admin', file);
const configFile = await loadFile(filePath);

if (configFile) {
return { path: filePath, config: configFile };
if (await pathExists(filePath)) {
return {
path: filePath,
modulePath: convertSystemPathToModulePath(path.relative(runtimeDir, filePath)),
};
}
}

Expand Down
37 changes: 35 additions & 2 deletions packages/core/admin/_internal/node/core/files.ts
@@ -1,3 +1,4 @@
import path from 'node:path';
import { access } from 'node:fs/promises';
import { register } from 'esbuild-register/dist/node';

Expand All @@ -18,7 +19,9 @@ const pathExists = async (path: string) => {
*/
const loadFile = async (path: string): Promise<undefined | any> => {
if (await pathExists(path)) {
const esbuildOptions = { extensions: ['.js', '.mjs', '.ts'] };
const esbuildOptions: Parameters<typeof register>[0] = {
extensions: ['.js', '.mjs', '.ts'],
};

const { unregister } = register(esbuildOptions);

Expand All @@ -38,4 +41,34 @@ const loadFile = async (path: string): Promise<undefined | any> => {
return undefined;
};

export { pathExists, loadFile };
/**
* @internal
*
* @description Converts a system path to a module path mainly for `Windows` systems.
* where the path separator is `\` instead of `/`, on linux systems the path separator
* is identical to the module path separator.
*/
const convertSystemPathToModulePath = (sysPath: string) => {
if (process.platform === 'win32') {
return sysPath.split(path.sep).join(path.posix.sep);
} else {
return sysPath;
}
};

/**
* @internal
*
* @description Converts a module path to a system path, again largely used for Windows systems.
* The original use case was plugins where the resolve path was in module format but we want to
* have it relative to the runtime directory.
*/
const convertModulePathToSystemPath = (modulePath: string) => {
if (process.platform === 'win32') {
return modulePath.split(path.posix.sep).join(path.sep);
} else {
return modulePath;
}
};

export { pathExists, loadFile, convertSystemPathToModulePath, convertModulePathToSystemPath };

0 comments on commit 133b68e

Please sign in to comment.