Skip to content

Commit 75e9f4c

Browse files
committed
Merge branch 'master' of github.com:pluginpal/strapi-plugin-config-sync
2 parents 5fc0aea + 748a31a commit 75e9f4c

33 files changed

+219
-185
lines changed

playground/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ coverage
108108
# Strapi
109109
############################
110110

111-
# .env
112111
license.txt
113112
exports
114-
*.cache
113+
.strapi
114+
dist
115115
build
116116
.strapi-updater.json
117+
.strapi-cloud.json
117118

118119
# yalc
119120
.yalc

playground/.strapi/client/app.js

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

playground/.strapi/client/index.html

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

playground/__tests__/cli.test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,47 @@ describe('Test the config-sync CLI', () => {
5858
}
5959
expect(error).toHaveProperty('code', 1);
6060
});
61+
62+
test('Import build project', async () => {
63+
// First we make sure the dist folder is deleted.
64+
await exec('mv dist .tmp');
65+
66+
await exec('yarn cs import -y');
67+
68+
const { stdout: buildOutput } = await exec('ls dist');
69+
expect(buildOutput).toContain('config');
70+
expect(buildOutput).toContain('src');
71+
expect(buildOutput).toContain('tsconfig.tsbuildinfo');
72+
73+
// We restore the dist folder.
74+
await exec('rm -rf dist');
75+
await exec('mv .tmp/dist ./dist');
76+
77+
});
78+
test('Import project already built', async () => {
79+
80+
81+
// First we make sure the dist folder exists by doing an import.
82+
await exec('yarn cs import -y');
83+
84+
const { stdout: lsDist } = await exec('ls dist');
85+
expect(lsDist).toContain('config');
86+
expect(lsDist).toContain('src');
87+
expect(lsDist).toContain('tsconfig.tsbuildinfo');
88+
89+
// We remove on file from the dist folder
90+
await exec('mv dist/tsconfig.tsbuildinfo .tmp');
91+
92+
// The new import should not rebuild the project.
93+
await exec('yarn cs import -y');
94+
95+
const { stdout: buildOutput } = await exec('ls dist');
96+
expect(buildOutput).toContain('config');
97+
expect(buildOutput).toContain('src');
98+
expect(buildOutput).not.toContain('tsconfig.tsbuildinfo');
99+
100+
// We restore the tsconfig.tsbuildinfo file.
101+
await exec('mv .tmp/tsconfig.tsbuildinfo dist/tsconfig.tsbuildinfo');
102+
103+
});
61104
});

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.

playground/config/admin.js renamed to playground/config/admin.ts

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
});

playground/config/api.js renamed to playground/config/api.ts

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+
};

playground/config/middlewares.js renamed to playground/config/middlewares.ts

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',
Lines changed: 2 additions & 2 deletions
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+
});

playground/config/server.js renamed to playground/config/server.ts

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/jsconfig.json

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

playground/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
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": {
20-
"@strapi/plugin-cloud": "5.0.4",
21-
"@strapi/plugin-users-permissions": "5.0.4",
22-
"@strapi/strapi": "5.0.4",
24+
"@strapi/plugin-cloud": "5.16.0",
25+
"@strapi/plugin-users-permissions": "5.16.0",
26+
"@strapi/strapi": "5.16.0",
2327
"better-sqlite3": "9.4.3",
2428
"react": "^18.0.0",
2529
"react-dom": "^18.0.0",

playground/src/admin/app.example.js renamed to playground/src/admin/app.example.tsx

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
};

playground/src/admin/tsconfig.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "Bundler",
6+
"useDefineForClassFields": true,
7+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
8+
"allowJs": false,
9+
"skipLibCheck": true,
10+
"esModuleInterop": true,
11+
"allowSyntheticDefaultImports": true,
12+
"strict": true,
13+
"forceConsistentCasingInFileNames": true,
14+
"resolveJsonModule": true,
15+
"noEmit": true,
16+
"jsx": "react-jsx"
17+
},
18+
"include": ["../plugins/**/admin/src/**/*", "./"],
19+
"exclude": ["node_modules/", "build/", "dist/", "**/*.test.ts"]
20+
}

playground/src/admin/webpack.config.example.js

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { mergeConfig, type UserConfig } from 'vite';
2+
3+
export default (config: UserConfig) => {
4+
// Important: always return the modified config
5+
return mergeConfig(config, {
6+
resolve: {
7+
alias: {
8+
'@': '/src',
9+
},
10+
},
11+
});
12+
};

playground/src/api/home/controllers/home.js

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* home controller
3+
*/
4+
5+
import { factories } from '@strapi/strapi';
6+
7+
export default factories.createCoreController('api::home.home');

playground/src/api/home/routes/home.js

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
/**
3+
* home router
4+
*/
5+
6+
import { factories } from '@strapi/strapi';
7+
8+
export default factories.createCoreRouter('api::home.home');

playground/src/api/home/services/home.js

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* home service
3+
*/
4+
5+
import { factories } from '@strapi/strapi';
6+
7+
export default factories.createCoreService('api::home.home');

0 commit comments

Comments
 (0)