mirror of
https://github.com/strapi/strapi.git
synced 2025-06-27 00:41:25 +00:00
chore: convert other packages to pack-up (#18339)
* chore: convert logger to pack-up * chore: convert generators to TS * chore: convert generators/app * chore: convert core/types * chore: preserve modules for `generators/app`
This commit is contained in:
parent
293219f39f
commit
0b13b1b50a
@ -1,2 +0,0 @@
|
||||
// this is a failsafe file in case the package gets required as code
|
||||
module.exports = null;
|
@ -26,21 +26,23 @@
|
||||
"url": "https://strapi.io"
|
||||
}
|
||||
],
|
||||
"main": "index.js",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"./dist/**/!(*.d.ts.map)",
|
||||
"index.js"
|
||||
"./dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "run -T tsc -p tsconfig.build.json",
|
||||
"build:ts": "run build",
|
||||
"build": "pack-up build",
|
||||
"clean": "run -T rimraf ./dist",
|
||||
"lint": "run -T eslint .",
|
||||
"prepublishOnly": "yarn clean && yarn build",
|
||||
"test:ts": "run -T tsc --noEmit",
|
||||
"test:unit": "run -T jest",
|
||||
"test:unit:watch": "run -T jest --watch",
|
||||
"watch": "run -T tsc -p tsconfig.build.json -w --preserveWatchOutput"
|
||||
"watch": "pack-up watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@koa/cors": "3.4.3",
|
||||
@ -56,6 +58,7 @@
|
||||
"node-schedule": "2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@strapi/pack-up": "workspace:*",
|
||||
"@strapi/ts-zen": "^0.2.0",
|
||||
"@types/jest": "29.5.2",
|
||||
"@types/koa": "2.13.4",
|
||||
|
@ -39,20 +39,24 @@ describe('Utils.Object', () => {
|
||||
test('PickBy', () => {
|
||||
type('PickByString').isMappedType({
|
||||
properties: {
|
||||
// @ts-expect-error - Wants to be string[]
|
||||
foo: t.stringLiteral('bar'),
|
||||
bar: t.stringLiteral('foo'),
|
||||
},
|
||||
});
|
||||
type('PickByNumber').isMappedType({
|
||||
properties: {
|
||||
// @ts-expect-error - Wants to be string[]
|
||||
foobar: t.numberLiteral(2),
|
||||
},
|
||||
});
|
||||
type('PickByNever').isMappedType({
|
||||
// @ts-expect-error - Thinks it _must_ have a property
|
||||
properties: {},
|
||||
});
|
||||
type('PickByUnknown').isMappedType({
|
||||
properties: {
|
||||
// @ts-expect-error - Wants to be string[]
|
||||
foobar: t.numberLiteral(2),
|
||||
foo: t.stringLiteral('bar'),
|
||||
bar: t.stringLiteral('foo'),
|
||||
@ -60,7 +64,9 @@ describe('Utils.Object', () => {
|
||||
});
|
||||
type('PickByObj').isMappedType({
|
||||
properties: {
|
||||
// @ts-expect-error - Wants to be string[]
|
||||
foo: t.mappedType({ properties: { x: t.stringLiteral('bar') } }),
|
||||
// @ts-expect-error - Wants to be string[]
|
||||
bar: t.mappedType({ properties: { x: t.stringLiteral('foo') } }),
|
||||
},
|
||||
});
|
||||
|
@ -29,18 +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 && run copy-files",
|
||||
"build:ts": "run build",
|
||||
"build": "pack-up build && run copy-files",
|
||||
"clean": "run -T rimraf ./dist",
|
||||
"copy-files": "copyfiles -u 1 -a 'src/resources/files/**/*' 'src/resources/dot-files/**/*' 'src/resources/**/*.template' dist",
|
||||
"lint": "run -T eslint .",
|
||||
"prepublishOnly": "yarn clean && yarn build",
|
||||
"watch": "run -T tsc -w --preserveWatchOutput"
|
||||
"test:ts": "run -T tsc --noEmit",
|
||||
"watch": "pack-up watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sentry/node": "6.19.7",
|
||||
@ -56,6 +58,7 @@
|
||||
"tar": "6.1.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@strapi/pack-up": "workspace:*",
|
||||
"copyfiles": "2.4.1"
|
||||
},
|
||||
"engines": {
|
||||
|
8
packages/generators/app/packup.config.ts
Normal file
8
packages/generators/app/packup.config.ts
Normal file
@ -0,0 +1,8 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { defineConfig } from '@strapi/pack-up';
|
||||
|
||||
export default defineConfig({
|
||||
externals: ['crypto', 'fs', 'node:fs', 'node:os', 'node:path', 'node:readline', 'os', 'path'],
|
||||
preserveModules: true,
|
||||
runtime: 'node',
|
||||
});
|
@ -12,6 +12,9 @@ import mergeTemplate from './utils/merge-template.js';
|
||||
import tryGitInit from './utils/git';
|
||||
|
||||
import packageJSON from './resources/json/common/package.json';
|
||||
import jsconfig from './resources/json/js/jsconfig.json';
|
||||
import adminTsconfig from './resources/json/ts/tsconfig-admin.json';
|
||||
import serverTsconfig from './resources/json/ts/tsconfig-server.json';
|
||||
import { createDatabaseConfig, generateDbEnvariables } from './resources/templates/database';
|
||||
import createEnvFile from './resources/templates/env';
|
||||
import { Configuration, Scope, isStderrError } from './types';
|
||||
@ -79,31 +82,27 @@ export default async function createProject(
|
||||
await trackUsage({ event: 'didWritePackageJSON', scope });
|
||||
|
||||
if (useTypescript) {
|
||||
const tsJSONDir = join(__dirname, 'resources/json/ts');
|
||||
const filesMap = {
|
||||
'tsconfig-admin.json.js': 'src/admin',
|
||||
'tsconfig-server.json.js': '.',
|
||||
};
|
||||
|
||||
for (const [fileName, path] of Object.entries(filesMap)) {
|
||||
const srcPath = join(tsJSONDir, fileName);
|
||||
const destPath = join(rootPath, path, 'tsconfig.json');
|
||||
|
||||
const json = require(srcPath).default();
|
||||
|
||||
await fse.writeJSON(destPath, json, { spaces: 2 });
|
||||
if (fileName === 'tsconfig-admin.json.js') {
|
||||
await fse.writeJSON(destPath, adminTsconfig(), { spaces: 2 });
|
||||
}
|
||||
if (fileName === 'tsconfig-server.json.js') {
|
||||
await fse.writeJSON(destPath, serverTsconfig(), { spaces: 2 });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const jsJSONDir = join(__dirname, 'resources/json/js');
|
||||
const filesMap = { 'jsconfig.json.js': '.' };
|
||||
|
||||
for (const [fileName, path] of Object.entries(filesMap)) {
|
||||
const srcPath = join(jsJSONDir, fileName);
|
||||
for (const [, path] of Object.entries(filesMap)) {
|
||||
const destPath = join(rootPath, path, 'jsconfig.json');
|
||||
|
||||
const json = require(srcPath).default();
|
||||
|
||||
await fse.writeJSON(destPath, json, { spaces: 2 });
|
||||
await fse.writeJSON(destPath, jsconfig(), { spaces: 2 });
|
||||
}
|
||||
}
|
||||
|
||||
|
7
packages/generators/app/tsconfig.build.json
Normal file
7
packages/generators/app/tsconfig.build.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": ["**/__tests__/**", "src/resources/files"]
|
||||
}
|
@ -3,6 +3,6 @@
|
||||
"compilerOptions": {
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"include": ["src", "packup.config.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
{
|
||||
"extends": "tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"target": "ES2021"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/**", "src/resources/files"]
|
||||
"exclude": ["node_modules", "src/resources/files"]
|
||||
}
|
||||
|
@ -28,20 +28,22 @@
|
||||
}
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"./dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "run -T tsc && run copy-files",
|
||||
"build:ts": "run build",
|
||||
"build": "pack-up build && run copy-files",
|
||||
"clean": "run -T rimraf ./dist",
|
||||
"copy-files": "copyfiles -u 1 -a 'src/templates/**/*' 'src/files/**/*' dist",
|
||||
"lint": "run -T eslint .",
|
||||
"prepublishOnly": "yarn clean && yarn build",
|
||||
"test:ts": "run -T tsc --noEmit",
|
||||
"test:unit": "run -T jest",
|
||||
"test:unit:watch": "run -T jest --watch",
|
||||
"watch": "run -T tsc -w --preserveWatchOutput"
|
||||
"watch": "pack-up watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sindresorhus/slugify": "1.1.0",
|
||||
@ -55,6 +57,7 @@
|
||||
"pluralize": "8.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@strapi/pack-up": "workspace:*",
|
||||
"eslint-config-custom": "4.14.4",
|
||||
"tsconfig": "4.14.4"
|
||||
},
|
||||
|
14
packages/generators/generators/packup.config.ts
Normal file
14
packages/generators/generators/packup.config.ts
Normal file
@ -0,0 +1,14 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { defineConfig } from '@strapi/pack-up';
|
||||
|
||||
export default defineConfig({
|
||||
bundles: [
|
||||
{
|
||||
source: './src/plopfile.ts',
|
||||
require: './dist/plopfile.js',
|
||||
import: './dist/plopfile.mjs',
|
||||
},
|
||||
],
|
||||
externals: ['node:path', 'path'],
|
||||
runtime: 'node',
|
||||
});
|
7
packages/generators/generators/tsconfig.build.json
Normal file
7
packages/generators/generators/tsconfig.build.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": ["**/__tests__/**", "src/files", "src/templates"]
|
||||
}
|
@ -3,6 +3,6 @@
|
||||
"compilerOptions": {
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"include": ["src", "packup.config.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
{
|
||||
"extends": "tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/**", "src/files", "src/templates"]
|
||||
"exclude": ["node_modules", "src/files", "src/templates"]
|
||||
}
|
||||
|
@ -24,23 +24,26 @@
|
||||
}
|
||||
],
|
||||
"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",
|
||||
"build": "pack-up build",
|
||||
"clean": "run -T rimraf ./dist",
|
||||
"lint": "run -T eslint .",
|
||||
"prepublishOnly": "yarn clean && yarn build",
|
||||
"watch": "run -T tsc -w --preserveWatchOutput"
|
||||
"test:ts": "run -T tsc --noEmit",
|
||||
"watch": "pack-up watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": "4.17.21",
|
||||
"winston": "3.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@strapi/pack-up": "workspace:*",
|
||||
"eslint-config-custom": "4.14.4",
|
||||
"tsconfig": "4.14.4"
|
||||
},
|
||||
|
6
packages/utils/logger/packup.config.ts
Normal file
6
packages/utils/logger/packup.config.ts
Normal file
@ -0,0 +1,6 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { defineConfig } from '@strapi/pack-up';
|
||||
|
||||
export default defineConfig({
|
||||
runtime: 'node',
|
||||
});
|
@ -1,3 +1,4 @@
|
||||
export { default as prettyPrint, PrettyPrintOptions } from './pretty-print';
|
||||
export { default as prettyPrint } from './pretty-print';
|
||||
export type { PrettyPrintOptions } from './pretty-print';
|
||||
export { default as levelFilter } from './level-filter';
|
||||
export { default as excludeColors } from './exclude-colors';
|
||||
|
8
packages/utils/logger/tsconfig.build.json
Normal file
8
packages/utils/logger/tsconfig.build.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/**"]
|
||||
}
|
@ -1,6 +1,3 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
},
|
||||
"extends": "./tsconfig"
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
{
|
||||
"extends": "tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/**"]
|
||||
"include": ["src", "packup.config.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
const rimraf = require('rimraf');
|
||||
const execa = require('execa');
|
||||
const generateNew = require('../../packages/generators/app/dist/generate-new').default;
|
||||
const generateNew = require('../../packages/generators/app/dist/generate-new');
|
||||
|
||||
/**
|
||||
* Deletes a test app
|
||||
|
@ -7639,6 +7639,7 @@ __metadata:
|
||||
resolution: "@strapi/generate-new@workspace:packages/generators/app"
|
||||
dependencies:
|
||||
"@sentry/node": 6.19.7
|
||||
"@strapi/pack-up": "workspace:*"
|
||||
chalk: ^4.1.2
|
||||
copyfiles: 2.4.1
|
||||
execa: 5.1.1
|
||||
@ -7658,6 +7659,7 @@ __metadata:
|
||||
resolution: "@strapi/generators@workspace:packages/generators/generators"
|
||||
dependencies:
|
||||
"@sindresorhus/slugify": 1.1.0
|
||||
"@strapi/pack-up": "workspace:*"
|
||||
"@strapi/typescript-utils": 4.14.4
|
||||
"@strapi/utils": 4.14.4
|
||||
chalk: 4.1.2
|
||||
@ -7750,6 +7752,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@strapi/logger@workspace:packages/utils/logger"
|
||||
dependencies:
|
||||
"@strapi/pack-up": "workspace:*"
|
||||
eslint-config-custom: 4.14.4
|
||||
lodash: 4.17.21
|
||||
tsconfig: 4.14.4
|
||||
@ -8347,6 +8350,7 @@ __metadata:
|
||||
"@koa/router": 10.1.1
|
||||
"@strapi/database": 4.14.4
|
||||
"@strapi/logger": 4.14.4
|
||||
"@strapi/pack-up": "workspace:*"
|
||||
"@strapi/permissions": 4.14.4
|
||||
"@strapi/ts-zen": ^0.2.0
|
||||
"@strapi/utils": 4.14.4
|
||||
|
Loading…
x
Reference in New Issue
Block a user