Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions playground/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ coverage
# Strapi
############################

# .env
license.txt
exports
*.cache
.strapi
dist
build
.strapi-updater.json
.strapi-cloud.json

# yalc
.yalc
Expand Down
16 changes: 0 additions & 16 deletions playground/.strapi/client/app.js

This file was deleted.

63 changes: 0 additions & 63 deletions playground/.strapi/client/index.html

This file was deleted.

36 changes: 36 additions & 0 deletions playground/__tests__/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,40 @@ describe('Test the config-sync CLI', () => {
}
expect(error).toHaveProperty('code', 1);
});

test('Import build project', async () => {
// First we make sure the dist folder is deleted.
await exec('rm -rf dist');

await exec('yarn cs import -y');

const { stdout: buildOutput } = await exec('ls dist');
expect(buildOutput).toContain('config');
expect(buildOutput).toContain('src');
expect(buildOutput).toContain('tsconfig.tsbuildinfo');

});
test('Import project already built', async () => {


// First we make sure the dist folder exists by doing an import.
await exec('yarn cs import -y');

const { stdout: lsDist } = await exec('ls dist');
expect(lsDist).toContain('config');
expect(lsDist).toContain('src');
expect(lsDist).toContain('tsconfig.tsbuildinfo');

// We remove on file from the dist folder
await exec('mv dist/tsconfig.tsbuildinfo .tmp');

// The new import should not rebuild the project.
await exec('yarn cs import -y');

const { stdout: buildOutput } = await exec('ls dist');
expect(buildOutput).toContain('config');
expect(buildOutput).toContain('src');
expect(buildOutput).not.toContain('tsconfig.tsbuildinfo');

});
});
10 changes: 5 additions & 5 deletions playground/__tests__/import-on-boostrap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jest.setTimeout(20000);

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

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

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

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

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

// Remove a config file to make sure the importOnBoostrap
// function actually attempts to import.
Expand Down
5 changes: 2 additions & 3 deletions playground/config/admin.js → playground/config/admin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = ({ env }) => ({
export default ({ env }) => ({
auth: {
secret: env('ADMIN_JWT_SECRET'),
},
Expand All @@ -19,6 +19,5 @@ module.exports = ({ env }) => ({
},
watchIgnoreFiles: [
'!**/.yalc/**/server/**',
'**/config/sync/**',
]
],
});
2 changes: 1 addition & 1 deletion playground/config/api.js → playground/config/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
rest: {
defaultLimit: 25,
maxLimit: 100,
Expand Down
11 changes: 0 additions & 11 deletions playground/config/database.js

This file was deleted.

15 changes: 15 additions & 0 deletions playground/config/database.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import path from 'path';

export default ({ env }) => {

return {
connection: {
client: 'sqlite',
connection: {
filename: path.join(__dirname, '..', '..', env('DATABASE_FILENAME', '.tmp/data.db')),
},
useNullAsDefault: true,
},
};

};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'strapi::logger',
'strapi::errors',
'strapi::security',
Expand Down
4 changes: 2 additions & 2 deletions playground/config/plugins.js → playground/config/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
export default () => ({
'config-sync': {
enabled: true,
config: {
importOnBootstrap: false,
minify: true,
},
},
};
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = ({ env }) => ({
export default ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
app: {
Expand Down
8 changes: 0 additions & 8 deletions playground/jsconfig.json

This file was deleted.

10 changes: 7 additions & 3 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
"cs": "config-sync"
},
"devDependencies": {
"@types/node": "^24.0.7",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
"supertest": "^6.3.3",
"typescript": "^5.8.3",
"yalc": "^1.0.0-pre.53"
},
"dependencies": {
"@strapi/plugin-cloud": "5.0.4",
"@strapi/plugin-users-permissions": "5.0.4",
"@strapi/strapi": "5.0.4",
"@strapi/plugin-cloud": "5.16.0",
"@strapi/plugin-users-permissions": "5.16.0",
"@strapi/strapi": "5.16.0",
"better-sqlite3": "9.4.3",
"react": "^18.0.0",
"react-dom": "^18.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { StrapiApp } from '@strapi/strapi/admin';

export default {
config: {
locales: [
Expand Down Expand Up @@ -29,7 +31,7 @@ export default {
// 'zh',
],
},
bootstrap(app) {
bootstrap(app: StrapiApp) {
console.log(app);
},
};
20 changes: 20 additions & 0 deletions playground/src/admin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["../plugins/**/admin/src/**/*", "./"],
"exclude": ["node_modules/", "build/", "dist/", "**/*.test.ts"]
}
9 changes: 0 additions & 9 deletions playground/src/admin/webpack.config.example.js

This file was deleted.

12 changes: 12 additions & 0 deletions playground/src/admin/webpack.config.example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { mergeConfig, type UserConfig } from 'vite';

export default (config: UserConfig) => {
// Important: always return the modified config
return mergeConfig(config, {
resolve: {
alias: {
'@': '/src',
},
},
});
};
9 changes: 0 additions & 9 deletions playground/src/api/home/controllers/home.js

This file was deleted.

7 changes: 7 additions & 0 deletions playground/src/api/home/controllers/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* home controller
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreController('api::home.home');
9 changes: 0 additions & 9 deletions playground/src/api/home/routes/home.js

This file was deleted.

8 changes: 8 additions & 0 deletions playground/src/api/home/routes/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

/**
* home router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::home.home');
9 changes: 0 additions & 9 deletions playground/src/api/home/services/home.js

This file was deleted.

7 changes: 7 additions & 0 deletions playground/src/api/home/services/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* home service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::home.home');
9 changes: 0 additions & 9 deletions playground/src/api/page/controllers/page.js

This file was deleted.

Loading
Loading