Merge branch 'main' into chore/ts_declaration_map

This commit is contained in:
Marc Roig 2023-10-05 17:53:07 +02:00 committed by GitHub
commit 66cf7de61b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
82 changed files with 331 additions and 211 deletions

View File

@ -10,6 +10,6 @@ export JWT_SECRET="aSecret"
opts=($DB_OPTIONS)
yarn nx run-many --target=build:ts --nx-ignore-cycles --skip-nx-cache
yarn nx run-many --target=build --nx-ignore-cycles --skip-nx-cache
yarn run test:generate-app --appPath=test-apps/api "${opts[@]}"
yarn run test:api --no-generate-app

View File

@ -54,8 +54,6 @@ jobs:
- uses: nrwl/nx-set-shas@v3
- name: Monorepo install
uses: ./.github/actions/yarn-nm-install
- name: Run build:ts
run: yarn nx run-many --target=build:ts --nx-ignore-cycles --skip-nx-cache
- name: Run build
run: yarn nx run-many --target=build --nx-ignore-cycles --skip-nx-cache
- name: Run lint
@ -75,8 +73,6 @@ jobs:
- uses: nrwl/nx-set-shas@v3
- name: Monorepo install
uses: ./.github/actions/yarn-nm-install
- name: Run build:ts
run: yarn nx run-many --target=build:ts --nx-ignore-cycles --skip-nx-cache
- name: Run build
run: yarn nx run-many --target=build --nx-ignore-cycles --skip-nx-cache
- name: TSC for packages
@ -103,10 +99,8 @@ jobs:
- uses: nrwl/nx-set-shas@v3
- name: Monorepo install
uses: ./.github/actions/yarn-nm-install
- name: Run build:ts
run: yarn nx run-many --target=build:ts --nx-ignore-cycles --skip-nx-cache
- name: Run build
run: yarn build --projects=@strapi/pack-up --skip-nx-cache
run: yarn build --skip-nx-cache
- name: Run tests
run: yarn nx affected --target=test:unit --nx-ignore-cycles
@ -127,7 +121,7 @@ jobs:
- uses: nrwl/nx-set-shas@v3
- name: Monorepo install
uses: ./.github/actions/yarn-nm-install
- name: Run build:ts for admin-test-utils
- name: Run build for admin-test-utils
run: yarn build --projects=@strapi/admin-test-utils,@strapi/helper-plugin --skip-nx-cache
- name: Run test
run: yarn nx affected --target=test:front --nx-ignore-cycles
@ -173,9 +167,6 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright@1.38.1 install --with-deps
- name: Run build:ts
run: yarn nx run-many --target=build:ts --nx-ignore-cycles --skip-nx-cache
- name: Run build
run: yarn nx run-many --target=build --nx-ignore-cycles --skip-nx-cache

View File

@ -19,6 +19,6 @@ test.describe('List View', () => {
await expect(page).toHaveTitle('Content Manager');
await expect(page.getByRole('heading', { name: 'testing' })).toBeVisible();
await expect(page.getByRole('link', { name: /Create new entry/ })).toBeVisible();
await expect(page.getByRole('link', { name: /Create new entry/ }).first()).toBeVisible();
});
});

View File

@ -721,7 +721,7 @@ function ListView({
{/* Empty content */}
<Table.EmptyBody
contentType={headerLayoutTitle}
aciton={getCreateAction({ variant: 'secondary' })}
action={getCreateAction({ variant: 'secondary' })}
/>
{/* Content */}
<Body.Root

View File

@ -0,0 +1 @@
export const useNavigatorOnline = () => true;

View File

@ -1,18 +1,18 @@
import { act, renderHook, waitFor } from '@testing-library/react';
import useNavigatorOnLine from '../index';
import { useNavigatorOnline } from '../useNavigatorOnline';
describe('useNavigatorOnLine', () => {
describe('useNavigatorOnline', () => {
it('returns the online state', () => {
jest.spyOn(window.navigator, 'onLine', 'get').mockReturnValue(true);
const { result } = renderHook(() => useNavigatorOnLine());
const { result } = renderHook(() => useNavigatorOnline());
expect(result.current).toEqual(true);
});
it('returns the offline state', () => {
jest.spyOn(window.navigator, 'onLine', 'get').mockReturnValue(false);
const { result } = renderHook(() => useNavigatorOnLine());
const { result } = renderHook(() => useNavigatorOnline());
expect(result.current).toEqual(false);
});
@ -20,7 +20,7 @@ describe('useNavigatorOnLine', () => {
it('listens for network change online', async () => {
// Initialize an offline state
jest.spyOn(window.navigator, 'onLine', 'get').mockReturnValue(false);
const { result } = renderHook(() => useNavigatorOnLine());
const { result } = renderHook(() => useNavigatorOnline());
await act(async () => {
// Simulate a change from offline to online
@ -35,7 +35,7 @@ describe('useNavigatorOnLine', () => {
it('listens for network change offline', async () => {
// Initialize an online state
jest.spyOn(window.navigator, 'onLine', 'get').mockReturnValue(true);
const { result } = renderHook(() => useNavigatorOnLine());
const { result } = renderHook(() => useNavigatorOnline());
await act(async () => {
// Simulate a change from online to offline

View File

@ -1,21 +1,21 @@
import { useEffect, useState } from 'react';
import * as React from 'react';
/**
* For more details about this hook see:
* https://www.30secondsofcode.org/react/s/use-navigator-on-line
*/
const useNavigatorOnLine = () => {
export const useNavigatorOnline = (): boolean => {
const onlineStatus =
typeof navigator !== 'undefined' && typeof navigator.onLine === 'boolean'
? navigator.onLine
: true;
const [isOnline, setIsOnline] = useState(onlineStatus);
const [isOnline, setIsOnline] = React.useState(onlineStatus);
const setOnline = () => setIsOnline(true);
const setOffline = () => setIsOnline(false);
useEffect(() => {
React.useEffect(() => {
window.addEventListener('online', setOnline);
window.addEventListener('offline', setOffline);
@ -27,5 +27,3 @@ const useNavigatorOnLine = () => {
return isOnline;
};
export default useNavigatorOnLine;

View File

@ -26,7 +26,6 @@ import { useIntl } from 'react-intl';
import { useSelector } from 'react-redux';
import useDebounce from '../../hooks/useDebounce';
import useNavigatorOnLine from '../../hooks/useNavigatorOnLine';
import { selectAdminPermissions } from '../App/selectors';
import MissingPluginBanner from './components/MissingPluginBanner';
@ -36,6 +35,7 @@ import NpmPackagesPagination from './components/NpmPackagesPagination';
import OfflineLayout from './components/OfflineLayout';
import PageHeader from './components/PageHeader';
import SortSelect from './components/SortSelect';
import { useNavigatorOnline } from './hooks/useNavigatorOnline';
import useMarketplaceData from './utils/useMarketplaceData';
const MarketPlacePage = () => {
@ -47,7 +47,7 @@ const MarketPlacePage = () => {
const debouncedSearch = useDebounce(query?.search, 500) || '';
const { autoReload: isInDevelopmentMode, dependencies, useYarn, strapiVersion } = useAppInfo();
const isOnline = useNavigatorOnLine();
const isOnline = useNavigatorOnline();
const npmPackageType = query?.npmPackageType || 'plugin';

View File

@ -12,7 +12,7 @@ import { MarketPlacePage } from '../index';
import server from './server';
jest.mock('../../../hooks/useNavigatorOnLine', () => jest.fn(() => true));
jest.mock('../hooks/useNavigatorOnline');
jest.mock('@strapi/helper-plugin', () => ({
...jest.requireActual('@strapi/helper-plugin'),

View File

@ -14,7 +14,7 @@ import server from './server';
// Increase the jest timeout to accommodate long running tests
jest.setTimeout(50000);
jest.mock('../../../hooks/useNavigatorOnLine', () => jest.fn(() => true));
jest.mock('../hooks/useNavigatorOnline');
jest.mock('../../../hooks/useDebounce', () => (value) => value);
jest.mock('@strapi/helper-plugin', () => ({
...jest.requireActual('@strapi/helper-plugin'),

View File

@ -19,7 +19,7 @@ jest.setTimeout(50000);
* MOCKS
*/
jest.mock('../../../hooks/useDebounce', () => (value) => value);
jest.mock('../../../hooks/useNavigatorOnLine', () => jest.fn(() => true));
jest.mock('../hooks/useNavigatorOnline');
jest.mock('@strapi/helper-plugin', () => ({
...jest.requireActual('@strapi/helper-plugin'),
useAppInfo: jest.fn(() => ({

View File

@ -1,50 +0,0 @@
// temporary solution found from https://stackoverflow.com/a/41641001/10434847
import { ValidationError as ActualYupValidationError } from 'yup';
export namespace errors {
export declare class ApplicationError<TDetails = unknown> extends Error {
details: TDetails;
constructor(message?: string, details?: TDetails);
}
export declare class ValidationError<TDetails = unknown> extends ApplicationError<TDetails> {
constructor(message?: string, details?: unknown);
}
export interface YupFormattedError {
path: string[];
message: string;
name: string;
}
export declare class YupValidationError extends ValidationError<{
errors: Array<YupFormattedError>;
}> {
constructor(yupError: ActualYupValidationError, message?: string);
}
export declare class PaginationError extends ApplicationError {
constructor(message?: string, details?: unknown);
}
export declare class NotFoundError extends ApplicationError {
constructor(message?: string, details?: unknown);
}
export declare class ForbiddenError extends ApplicationError {
constructor(message?: string, details?: unknown);
}
export declare class UnauthorizedError extends ApplicationError {
constructor(message?: string, details?: unknown);
}
export declare class RateLimitError extends ApplicationError {
constructor(message?: string, details?: unknown);
}
export declare class PayloadTooLargeError extends ApplicationError {
constructor(message?: string, details?: unknown);
}
export declare class PolicyError extends ForbiddenError {
constructor(message?: string, details?: unknown);
}
export declare class NotImplementedError extends ApplicationError {
constructor(message?: string, details?: unknown);
}
}

View File

@ -17,8 +17,14 @@ interface NormalizeErrorReturn {
values: Record<'path', string> | Record<string, never>;
}
interface YupFormattedError {
path: string[];
message: string;
name: string;
}
function normalizeError(
error: ApiError | errors.YupFormattedError,
error: ApiError | YupFormattedError,
{ name, intlMessagePrefixCallback }: NormalizeErrorOptions
): NormalizeErrorReturn {
const { message } = error;
@ -37,7 +43,9 @@ function normalizeError(
return normalizedError;
}
const validateErrorIsYupValidationError = (err: ApiError): err is errors.YupValidationError =>
const validateErrorIsYupValidationError = (
err: ApiError
): err is errors.YupValidationError & { details: { errors: YupFormattedError[] } } =>
typeof err.details === 'object' && err.details !== null && 'errors' in err.details;
export function normalizeAPIError(

View File

@ -92,7 +92,7 @@ describe('UploadAssetDialog', () => {
fireEvent.click(getByRole('button', { name: 'Next' }));
await waitFor(() => expect(screen.getByText('An error occured')).toBeInTheDocument());
});
}, 10000);
it('snapshots the component with 4 URLs: 3 valid and one in failure', async () => {
const { user, getByText, getByRole } = render(<UploadAssetDialog />);

View File

@ -28,22 +28,20 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist/**/!(*.d.ts.map)"
],
"directories": {
"lib": "./lib"
},
"scripts": {
"build": "run -T tsc",
"build:ts": "run build",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"test:unit": "run -T jest",
"test:unit:watch": "run -T jest --watch",
"lint": "run -T eslint ."
"watch": "run -T pack-up watch"
},
"dependencies": {
"@sindresorhus/slugify": "1.1.0",
@ -54,6 +52,7 @@
"yup": "0.32.9"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"@types/koa": "2.13.4",
"@types/node": "18.11.9",
"eslint-config-custom": "4.14.3",

View File

@ -0,0 +1,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
externals: ['node:stream'],
runtime: 'node',
});

View File

@ -1,12 +1,10 @@
/* eslint-disable @typescript-eslint/no-namespace */
/**
* Export shared utilities
*/
import type * as yupTypes from 'yup';
import parseMultipartData from './parse-multipart';
import { parseMultipartData } from './parse-multipart';
import parseType from './parse-type';
import * as policy from './policy';
import templateConfiguration from './template-configuration';
import { templateConfiguration } from './template-configuration';
import { handleYupError, validateYupSchema, validateYupSchemaSync } from './validators';
import * as yup from './yup';
@ -47,24 +45,7 @@ import * as traverse from './traverse';
import webhook from './webhook';
import { isOperator, isOperatorOfType } from './operators';
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace utils {
export namespace yup {
export type BaseSchema = yupTypes.BaseSchema;
export type AnySchema = yupTypes.AnySchema;
export type NumberSchema = yupTypes.NumberSchema;
export type StringSchema = yupTypes.StringSchema;
export type BooleanSchema = yupTypes.BooleanSchema;
export type ObjectSchema = yupTypes.AnyObjectSchema;
export type ArraySchema<T extends yupTypes.AnySchema = any> = yupTypes.ArraySchema<T>;
export type LazySchema<T extends yupTypes.AnySchema = any> = ReturnType<
typeof yupTypes.lazy<T>
>;
}
}
// eslint-disable-next-line @typescript-eslint/no-redeclare
const utils = {
export {
parseMultipartData,
parseType,
policy,
@ -115,5 +96,3 @@ const utils = {
isOperator,
isOperatorOfType,
};
export = utils;

View File

@ -1,7 +1,7 @@
import _ from 'lodash';
import type Koa from 'koa';
export = (ctx: Koa.Context) => {
export const parseMultipartData = (ctx: Koa.Context) => {
if (!ctx.is('multipart')) {
return { data: ctx.request.body, files: {} };
}

View File

@ -50,4 +50,4 @@ function printValue(value: unknown, quoteStrings: boolean) {
);
}
export = printValue;
export { printValue };

View File

@ -31,4 +31,4 @@ const templateConfiguration = (obj: Record<string, unknown>, configPath = '') =>
}, {} as Record<string, unknown>);
};
export = templateConfiguration;
export { templateConfiguration };

View File

@ -4,7 +4,7 @@ import * as yup from 'yup';
import _ from 'lodash';
import { isNumber, isInteger, get } from 'lodash/fp';
import * as utils from './string-formatting';
import printValue from './print-value';
import { printValue } from './print-value';
export * from 'yup';

View File

@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -28,19 +28,21 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run -T tsc",
"build:ts": "run -T tsc",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"lint": "run -T eslint ."
"watch": "pack-up watch"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"@strapi/types": "4.14.3",
"eslint-config-custom": "4.14.3",
"tsconfig": "4.14.3"

View File

@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
runtime: 'node',
});

View File

@ -12,7 +12,7 @@ interface Log extends Omit<Event, 'userId'> {
user: string | number;
}
export = {
export default {
async register({ strapi }: { strapi: Strapi }) {
const contentTypes = strapi.container.get('content-types');
if (!contentTypes.keys().includes('admin::audit-log')) {

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -1,8 +1,5 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/**"]
"exclude": ["node_modules"]
}

View File

@ -29,23 +29,25 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run -T tsc",
"build:ts": "run -T tsc",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"lint": "run -T eslint ."
"watch": "pack-up watch"
},
"dependencies": {
"@strapi/utils": "4.14.3",
"node-ses": "^3.0.3"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"eslint-config-custom": "4.14.3",
"tsconfig": "4.14.3"
},

View File

@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
runtime: 'node',
});

View File

@ -23,7 +23,7 @@ interface ProviderOptions {
amazon?: string;
}
export = {
export default {
init(providerOptions: ProviderOptions, settings: Settings) {
const client = nodeSES.createClient(providerOptions);

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -1,8 +1,5 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/**"]
"exclude": ["node_modules"]
}

View File

@ -29,19 +29,20 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run -T tsc",
"build:ts": "run -T tsc",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"test:unit": "run -T jest",
"test:unit:watch": "run -T jest --watch",
"lint": "run -T eslint ."
"watch": "pack-up watch"
},
"dependencies": {
"@strapi/utils": "4.14.3",
@ -49,6 +50,7 @@
"mailgun.js": "8.2.1"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"eslint-config-custom": "4.14.3",
"tsconfig": "4.14.3"
},

View File

@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
runtime: 'node',
});

View File

@ -31,7 +31,7 @@ const optionsMap: Record<string, LegacyOptionMapper> = {
host: { field: 'url', fn: (value) => `https://${value || 'api.mailgun.net'}` },
};
export = {
export default {
convertProviderOptions(providerOptions: ProviderOptions): Record<string, unknown> {
const newOptions: Record<string, unknown> = {};
if (typeof providerOptions === 'object') {

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -1,8 +1,5 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/**"]
"exclude": ["node_modules"]
}

View File

@ -42,23 +42,25 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run -T tsc",
"build:ts": "run -T tsc",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"lint": "run -T eslint ."
"watch": "pack-up watch"
},
"dependencies": {
"lodash": "4.17.21",
"nodemailer": "6.9.1"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"@types/nodemailer": "6.4.7",
"eslint-config-custom": "4.14.3",
"tsconfig": "4.14.3"

View File

@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
runtime: 'node',
});

View File

@ -32,7 +32,7 @@ const emailFields = [
'attachments',
];
export = {
export default {
provider: 'nodemailer',
name: 'Nodemailer',

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -1,8 +1,5 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/**"]
"exclude": ["node_modules"]
}

View File

@ -29,23 +29,25 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run -T tsc",
"build:ts": "run -T tsc",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"lint": "run -T eslint ."
"watch": "pack-up watch"
},
"dependencies": {
"@sendgrid/mail": "7.7.0",
"@strapi/utils": "4.14.3"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"eslint-config-custom": "4.14.3",
"tsconfig": "4.14.3"
},

View File

@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
runtime: 'node',
});

View File

@ -21,7 +21,7 @@ interface ProviderOptions {
apiKey: string;
}
export = {
export default {
init(providerOptions: ProviderOptions, settings: Settings) {
sendgrid.setApiKey(providerOptions.apiKey);

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -1,8 +1,5 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/**"]
"exclude": ["node_modules"]
}

View File

@ -28,23 +28,25 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run -T tsc",
"build:ts": "run -T tsc",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"lint": "run -T eslint ."
"watch": "pack-up watch"
},
"dependencies": {
"@strapi/utils": "4.14.3",
"sendmail": "^1.6.1"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"@types/sendmail": "1.4.4",
"eslint-config-custom": "4.14.3",
"tsconfig": "4.14.3"

View File

@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
runtime: 'node',
});

View File

@ -19,7 +19,7 @@ interface SendOptions {
type ProviderOptions = Options;
export = {
export default {
init(providerOptions: ProviderOptions, settings: Settings) {
const sendmail = sendmailFactory({
silent: true,

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -1,8 +1,5 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/**"]
"exclude": ["node_modules"]
}

View File

@ -30,25 +30,27 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run -T tsc",
"build:ts": "run -T tsc",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"test:unit": "run -T jest",
"test:unit:watch": "run -T jest --watch",
"lint": "run -T eslint ."
"watch": "pack-up watch"
},
"dependencies": {
"aws-sdk": "2.1437.0",
"lodash": "4.17.21"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"@types/jest": "29.5.2",
"eslint-config-custom": "4.14.3",
"tsconfig": "4.14.3"

View File

@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
runtime: 'node',
});

View File

@ -44,7 +44,7 @@ interface InitOptions extends Partial<AWS.S3.ClientConfiguration> {
};
}
export = {
export default {
init({ baseUrl, rootPath, s3Options, ...legacyS3Options }: InitOptions) {
if (Object.keys(legacyS3Options).length > 0) {
process.emitWarning(

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -1,8 +1,5 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/**"]
"exclude": ["node_modules"]
}

View File

@ -29,17 +29,18 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run -T tsc",
"build:ts": "run -T tsc",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"lint": "run -T eslint ."
"watch": "pack-up watch"
},
"dependencies": {
"@strapi/utils": "4.14.3",
@ -47,6 +48,7 @@
"into-stream": "^5.1.0"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"eslint-config-custom": "4.14.3",
"tsconfig": "4.14.3"
},

View File

@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
runtime: 'node',
});

View File

@ -23,7 +23,7 @@ interface File {
buffer?: Buffer;
}
export = {
export default {
init(options: ConfigOptions) {
cloudinary.config(options);

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -28,25 +28,27 @@
}
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run -T tsc",
"build:ts": "run -T tsc",
"watch": "run -T tsc -w --preserveWatchOutput",
"build": "pack-up build",
"clean": "run -T rimraf ./dist",
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"test:unit": "run -T jest",
"test:unit:watch": "run -T jest --watch",
"lint": "run -T eslint ."
"watch": "pack-up watch"
},
"dependencies": {
"@strapi/utils": "4.14.3",
"fs-extra": "10.0.0"
},
"devDependencies": {
"@strapi/pack-up": "workspace:*",
"@types/jest": "29.5.2",
"eslint-config-custom": "4.14.3",
"tsconfig": "4.14.3"

View File

@ -0,0 +1,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from '@strapi/pack-up';
export default defineConfig({
externals: ['stream', 'fs', 'path'],
runtime: 'node',
});

View File

@ -37,7 +37,7 @@ interface CheckFileSizeOptions {
sizeLimit?: number;
}
export = {
export default {
init({ sizeLimit: providerOptionsSizeLimit }: InitOptions = {}) {
// TODO V5: remove providerOptions sizeLimit
if (providerOptionsSizeLimit) {

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["**/__tests__/**"]
}

View File

@ -3,6 +3,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["src"],
"include": ["src", "packup.config.ts"],
"exclude": ["node_modules"]
}

View File

@ -1,8 +1,5 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/**"]
"exclude": ["node_modules"]
}

View File

@ -110,6 +110,12 @@ be exported by the package, e.g. CLI scripts or Node.js workers.
The path to the directory to which the bundled files should be written.
#### `exports`
- Type: `Record<string, Export>`
Overwrite or amend the parsed exports from your `package.json`.
#### `externals`
- Type: `string[]`

View File

@ -30,7 +30,6 @@
"url": "https://strapi.io"
}
],
"bin": "./bin/pack-up.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
@ -41,6 +40,11 @@
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"bin": "./bin/pack-up.js",
"files": [
"bin",
"dist"
@ -52,8 +56,8 @@
"lint": "run -T eslint .",
"prepublishOnly": "yarn clean && yarn build",
"test": "test:ts && test:unit",
"test:unit": "run -T jest",
"test:ts": "run -T tsc --noEmit",
"test:unit": "run -T jest",
"watch": "node -r esbuild-register scripts/watch"
},
"dependencies": {

View File

@ -4,10 +4,11 @@ import os from 'os';
import * as path from 'path';
import pkgUp from 'pkg-up';
import { Runtime } from '../createBuildContext';
import { Logger } from './logger';
import type { Export } from './exports';
import type { Runtime } from '../createBuildContext';
interface LoadConfigOptions {
cwd: string;
logger: Logger;
@ -69,6 +70,7 @@ interface ConfigBundle {
import?: string;
require?: string;
runtime?: Runtime;
types?: string;
}
interface ConfigOptions {
@ -77,6 +79,10 @@ interface ConfigOptions {
* @description the directory to output the bundle to.
*/
dist?: string;
/**
* @description Overwrite the default exports.
*/
exports?: ConfigProperty<Record<string, Export>>;
/**
* @description a list of external dependencies to exclude from the bundle.
* We already collect the dependencies & peerDeps from the package.json.
@ -96,5 +102,22 @@ const defineConfig = (configOptions: ConfigOptions): ConfigOptions => configOpti
type Config = ConfigOptions;
type ConfigPropertyResolver<T> = (currentValue: T) => T;
type ConfigProperty<T> = T | ConfigPropertyResolver<T>;
/** @internal */
export function resolveConfigProperty<T>(prop: ConfigProperty<T> | undefined, initialValue: T): T {
if (!prop) {
return initialValue;
}
if (typeof prop === 'function') {
return (prop as ConfigPropertyResolver<T>)(initialValue);
}
return prop;
}
export { loadConfig, defineConfig, CONFIG_FILE_NAMES };
export type { Config };

View File

@ -1,6 +1,7 @@
import browserslistToEsbuild from 'browserslist-to-esbuild';
import path from 'path';
import { resolveConfigProperty } from './core/config';
import { parseExports, ExtMap, Export } from './core/exports';
import { loadTsConfig } from './core/tsconfig';
@ -74,12 +75,14 @@ const createBuildContext = async ({
web: ['esnext'],
};
const exports = parseExports({ extMap, pkg }).reduce((acc, x) => {
const parsedExports = parseExports({ extMap, pkg }).reduce((acc, x) => {
const { _path: exportPath, ...exportEntry } = x;
return { ...acc, [exportPath]: exportEntry };
}, {} as Record<string, Export>);
const exports = resolveConfigProperty(config.exports, parsedExports);
const parsedExternals = [
...(pkg.dependencies ? Object.keys(pkg.dependencies) : []),
...(pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : []),

View File

@ -134,6 +134,17 @@ const createTasks =
output: bundle.import,
});
}
if (bundle.types) {
const importId = path.join(ctx.pkg.name, bundle.source);
dtsTask.entries.push({
importId,
exportPath: bundle.source,
sourcePath: bundle.source,
targetPath: bundle.types,
});
}
}
if (dtsTask.entries.length) {

View File

@ -8150,6 +8150,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@strapi/provider-audit-logs-local@workspace:packages/providers/audit-logs-local"
dependencies:
"@strapi/pack-up": "workspace:*"
"@strapi/types": 4.14.3
eslint-config-custom: 4.14.3
tsconfig: 4.14.3
@ -8160,6 +8161,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@strapi/provider-email-amazon-ses@workspace:packages/providers/email-amazon-ses"
dependencies:
"@strapi/pack-up": "workspace:*"
"@strapi/utils": 4.14.3
eslint-config-custom: 4.14.3
node-ses: ^3.0.3
@ -8171,6 +8173,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@strapi/provider-email-mailgun@workspace:packages/providers/email-mailgun"
dependencies:
"@strapi/pack-up": "workspace:*"
"@strapi/utils": 4.14.3
eslint-config-custom: 4.14.3
form-data: ^4.0.0
@ -8183,6 +8186,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@strapi/provider-email-nodemailer@workspace:packages/providers/email-nodemailer"
dependencies:
"@strapi/pack-up": "workspace:*"
"@types/nodemailer": 6.4.7
eslint-config-custom: 4.14.3
lodash: 4.17.21
@ -8196,6 +8200,7 @@ __metadata:
resolution: "@strapi/provider-email-sendgrid@workspace:packages/providers/email-sendgrid"
dependencies:
"@sendgrid/mail": 7.7.0
"@strapi/pack-up": "workspace:*"
"@strapi/utils": 4.14.3
eslint-config-custom: 4.14.3
tsconfig: 4.14.3
@ -8206,6 +8211,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@strapi/provider-email-sendmail@workspace:packages/providers/email-sendmail"
dependencies:
"@strapi/pack-up": "workspace:*"
"@strapi/utils": 4.14.3
"@types/sendmail": 1.4.4
eslint-config-custom: 4.14.3
@ -8218,6 +8224,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@strapi/provider-upload-aws-s3@workspace:packages/providers/upload-aws-s3"
dependencies:
"@strapi/pack-up": "workspace:*"
"@types/jest": 29.5.2
aws-sdk: 2.1437.0
eslint-config-custom: 4.14.3
@ -8230,6 +8237,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@strapi/provider-upload-cloudinary@workspace:packages/providers/upload-cloudinary"
dependencies:
"@strapi/pack-up": "workspace:*"
"@strapi/utils": 4.14.3
cloudinary: ^1.41.0
eslint-config-custom: 4.14.3
@ -8242,6 +8250,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@strapi/provider-upload-local@workspace:packages/providers/upload-local"
dependencies:
"@strapi/pack-up": "workspace:*"
"@strapi/utils": 4.14.3
"@types/jest": 29.5.2
eslint-config-custom: 4.14.3
@ -8414,6 +8423,7 @@ __metadata:
resolution: "@strapi/utils@workspace:packages/core/utils"
dependencies:
"@sindresorhus/slugify": 1.1.0
"@strapi/pack-up": "workspace:*"
"@types/koa": 2.13.4
"@types/node": 18.11.9
date-fns: 2.30.0