Skip to content

Commit c0253b5

Browse files
committed
feat: migrate playground to typescript
1 parent 1e78cca commit c0253b5

27 files changed

Lines changed: 156 additions & 92 deletions

playground/__tests__/import-on-boostrap.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jest.setTimeout(20000);
77

88
afterEach(async () => {
99
// Disable importOnBootstrap
10-
await exec('sed -i "s/importOnBootstrap: true/importOnBootstrap: false/g" config/plugins.js');
10+
await exec('sed -i "s/importOnBootstrap: true/importOnBootstrap: false/g" config/plugins.ts');
1111

1212
await cleanupStrapi();
1313
await exec('rm -rf config/sync');
@@ -19,8 +19,8 @@ describe('Test the importOnBootstrap feature', () => {
1919
await exec('yarn cs export -y');
2020
await exec('rm -rf .tmp');
2121

22-
// Manually change the plugins.js to enable importOnBoostrap.
23-
await exec('sed -i "s/importOnBootstrap: false/importOnBootstrap: true/g" config/plugins.js');
22+
// Manually change the plugins.ts to enable importOnBoostrap.
23+
await exec('sed -i "s/importOnBootstrap: false/importOnBootstrap: true/g" config/plugins.ts');
2424

2525
// Start up Strapi to initiate the importOnBootstrap function.
2626
await setupStrapi();
@@ -33,8 +33,8 @@ describe('Test the importOnBootstrap feature', () => {
3333
await exec('rm -rf .tmp');
3434
await exec('yarn cs export -y');
3535

36-
// Manually change the plugins.js to enable importOnBoostrap.
37-
await exec('sed -i "s/importOnBootstrap: false/importOnBootstrap: true/g" config/plugins.js');
36+
// Manually change the plugins.ts to enable importOnBoostrap.
37+
await exec('sed -i "s/importOnBootstrap: false/importOnBootstrap: true/g" config/plugins.ts');
3838

3939
// Remove a config file to make sure the importOnBoostrap
4040
// function actually attempts to import.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = ({ env }) => ({
1+
export default ({ env }) => ({
22
auth: {
33
secret: env('ADMIN_JWT_SECRET'),
44
},
@@ -19,6 +19,5 @@ module.exports = ({ env }) => ({
1919
},
2020
watchIgnoreFiles: [
2121
'!**/.yalc/**/server/**',
22-
'**/config/sync/**',
23-
]
22+
],
2423
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
rest: {
33
defaultLimit: 25,
44
maxLimit: 100,

playground/config/database.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

playground/config/database.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import path from 'path';
2+
3+
export default ({ env }) => {
4+
5+
return {
6+
connection: {
7+
client: 'sqlite',
8+
connection: {
9+
filename: path.join(__dirname, '..', '..', env('DATABASE_FILENAME', '.tmp/data.db')),
10+
},
11+
useNullAsDefault: true,
12+
},
13+
};
14+
15+
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = [
1+
export default [
22
'strapi::logger',
33
'strapi::errors',
44
'strapi::security',
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
module.exports = {
1+
export default () => ({
22
'config-sync': {
33
enabled: true,
44
config: {
55
importOnBootstrap: false,
66
minify: true,
77
},
88
},
9-
};
9+
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = ({ env }) => ({
1+
export default ({ env }) => ({
22
host: env('HOST', '0.0.0.0'),
33
port: env.int('PORT', 1337),
44
app: {

playground/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
"cs": "config-sync"
1212
},
1313
"devDependencies": {
14+
"@types/node": "^24.0.7",
15+
"@types/react": "^19.1.8",
16+
"@types/react-dom": "^19.1.6",
1417
"jest": "^29.7.0",
1518
"jest-cli": "^29.7.0",
1619
"supertest": "^6.3.3",
20+
"typescript": "^5.8.3",
1721
"yalc": "^1.0.0-pre.53"
1822
},
1923
"dependencies": {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { StrapiApp } from '@strapi/strapi/admin';
2+
13
export default {
24
config: {
35
locales: [
@@ -29,7 +31,7 @@ export default {
2931
// 'zh',
3032
],
3133
},
32-
bootstrap(app) {
34+
bootstrap(app: StrapiApp) {
3335
console.log(app);
3436
},
3537
};

0 commit comments

Comments
 (0)