@oak-digital/types-4-strapi-2 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +46 -0
- package/lib/readers/load-strapi/index.js +30 -14
- package/lib/readers/load-strapi/remote.js +3 -1
- package/package.json +4 -2
- package/tests/strapi-project/.editorconfig +0 -16
- package/tests/strapi-project/.env.example +0 -6
- package/tests/strapi-project/README.md +0 -57
- package/tests/strapi-project/config/admin.ts +0 -13
- package/tests/strapi-project/config/api.ts +0 -7
- package/tests/strapi-project/config/database.ts +0 -93
- package/tests/strapi-project/config/middlewares.ts +0 -12
- package/tests/strapi-project/config/server.ts +0 -10
- package/tests/strapi-project/database/migrations/.gitkeep +0 -0
- package/tests/strapi-project/favicon.png +0 -0
- package/tests/strapi-project/package-lock.json +0 -16125
- package/tests/strapi-project/package.json +0 -30
- package/tests/strapi-project/public/robots.txt +0 -3
- package/tests/strapi-project/public/uploads/.gitkeep +0 -0
- package/tests/strapi-project/src/admin/app.example.tsx +0 -35
- package/tests/strapi-project/src/admin/webpack.config.example.js +0 -9
- package/tests/strapi-project/src/api/.gitkeep +0 -0
- package/tests/strapi-project/src/api/collection-1/content-types/collection-1/schema.json +0 -18
- package/tests/strapi-project/src/api/collection-1/content-types/generated-type/schema.json +0 -18
- package/tests/strapi-project/src/api/collection-1/controllers/collection-1.ts +0 -7
- package/tests/strapi-project/src/api/collection-1/controllers/generated-type.ts +0 -7
- package/tests/strapi-project/src/api/collection-1/routes/collection-1.ts +0 -7
- package/tests/strapi-project/src/api/collection-1/routes/generated-type.ts +0 -7
- package/tests/strapi-project/src/api/collection-1/services/collection-1.ts +0 -7
- package/tests/strapi-project/src/api/collection-1/services/generated-type.ts +0 -7
- package/tests/strapi-project/src/api/standalone-controller/controllers/standalone-controller.ts +0 -13
- package/tests/strapi-project/src/components/my-category/all-types.json +0 -88
- package/tests/strapi-project/src/components/other-category/sub-component.json +0 -12
- package/tests/strapi-project/src/extensions/.gitkeep +0 -0
- package/tests/strapi-project/src/index.ts +0 -18
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: write
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags:
|
|
9
|
+
- v*.*.*
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
publish:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout
|
|
17
|
+
uses: actions/checkout@v3
|
|
18
|
+
|
|
19
|
+
- uses: pnpm/action-setup@v2
|
|
20
|
+
name: Install pnpm
|
|
21
|
+
id: pnpm-install
|
|
22
|
+
with:
|
|
23
|
+
version: 8
|
|
24
|
+
|
|
25
|
+
- name: Install Node.js
|
|
26
|
+
uses: actions/setup-node@v3
|
|
27
|
+
with:
|
|
28
|
+
node-version: 18
|
|
29
|
+
registry-url: 'https://registry.npmjs.org'
|
|
30
|
+
cache: pnpm
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: pnpm install
|
|
34
|
+
|
|
35
|
+
- name: Build
|
|
36
|
+
run: pnpm run build
|
|
37
|
+
|
|
38
|
+
- name: Publish
|
|
39
|
+
run: pnpm -r publish --access public --no-git-checks
|
|
40
|
+
env:
|
|
41
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
42
|
+
|
|
43
|
+
- name: Create release
|
|
44
|
+
run: npx changelogithub
|
|
45
|
+
env:
|
|
46
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
@@ -60,33 +60,49 @@ class LoadStrapiReader {
|
|
|
60
60
|
loadStrapi() {
|
|
61
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
62
|
const localRemoteFile = (0, posix_1.join)(__dirname, 'remote.js');
|
|
63
|
-
|
|
63
|
+
// TODO: Make better check if the path is absolute or not
|
|
64
|
+
const root = this.strapiRoot.startsWith('/') ||
|
|
65
|
+
this.strapiRoot.startsWith('\\') ||
|
|
66
|
+
this.strapiRoot.startsWith('~')
|
|
67
|
+
? ''
|
|
68
|
+
: process.cwd();
|
|
69
|
+
const remoteRemoteFile = (0, posix_1.join)(root, this.strapiRoot, '.t4s.remote.js');
|
|
70
|
+
const remoteOutputFile = (0, posix_1.join)(root, this.strapiRoot, '.t4s.contentTypes.json');
|
|
64
71
|
// Plant the remote execution file in the strapi project
|
|
65
72
|
yield (0, promises_1.cp)(localRemoteFile, remoteRemoteFile);
|
|
66
73
|
const output = yield new Promise((resolve, reject) => {
|
|
67
74
|
const remote = (0, child_process_1.spawn)('node', [remoteRemoteFile], {
|
|
68
75
|
cwd: this.strapiRoot,
|
|
69
76
|
});
|
|
70
|
-
const
|
|
71
|
-
remote.stdout.on('data', (chunk) => {
|
|
72
|
-
data.push(chunk);
|
|
73
|
-
});
|
|
77
|
+
const errData = [];
|
|
74
78
|
remote.stderr.on('data', (chunk) => {
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
remote.on('close', () => {
|
|
78
|
-
resolve(data.map((b) => b === null || b === void 0 ? void 0 : b.toString()).join(''));
|
|
79
|
-
});
|
|
80
|
-
remote.on('error', (err) => {
|
|
81
|
-
reject(err);
|
|
79
|
+
errData.push(chunk);
|
|
82
80
|
});
|
|
81
|
+
remote.on('close', (code) => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
if (code !== 0) {
|
|
83
|
+
reject(new Error(`Failed to spawn remote strapi: ${errData
|
|
84
|
+
.map((b) => { var _a; return (_a = b === null || b === void 0 ? void 0 : b.toString()) !== null && _a !== void 0 ? _a : ''; })
|
|
85
|
+
.join('')}`));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const output = yield (0, promises_1.readFile)(remoteOutputFile);
|
|
90
|
+
resolve(output.toString());
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
reject(err);
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
83
96
|
});
|
|
97
|
+
if (output.length <= 0) {
|
|
98
|
+
throw new Error('Remote program did not return any output');
|
|
99
|
+
}
|
|
84
100
|
let jsonParsed;
|
|
85
101
|
try {
|
|
86
102
|
jsonParsed = JSON.parse(output);
|
|
87
103
|
}
|
|
88
104
|
catch (err) {
|
|
89
|
-
console.error(err, output
|
|
105
|
+
console.error(err, output);
|
|
90
106
|
throw new Error('Failed to parse output from remote strapi');
|
|
91
107
|
}
|
|
92
108
|
let parsed;
|
|
@@ -98,7 +114,7 @@ class LoadStrapiReader {
|
|
|
98
114
|
throw new Error('Failed to parse output from remote strapi, something may be malformed');
|
|
99
115
|
}
|
|
100
116
|
// Remove the remote execution file after we're done
|
|
101
|
-
yield (0, promises_1.rm)(remoteRemoteFile);
|
|
117
|
+
yield Promise.all([(0, promises_1.rm)(remoteOutputFile), (0, promises_1.rm)(remoteRemoteFile)]);
|
|
102
118
|
return parsed;
|
|
103
119
|
});
|
|
104
120
|
}
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const Strapi = require('@strapi/strapi');
|
|
12
|
+
const fs = require('fs/promises');
|
|
12
13
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
13
14
|
const base = yield Strapi({
|
|
14
15
|
distDir: 'dist',
|
|
@@ -18,7 +19,8 @@ const Strapi = require('@strapi/strapi');
|
|
|
18
19
|
base.log.info = () => { };
|
|
19
20
|
const instance = yield base.load();
|
|
20
21
|
yield instance.server.mount();
|
|
21
|
-
console.log(JSON.stringify([instance.contentTypes, instance.components]));
|
|
22
|
+
// console.log(JSON.stringify([instance.contentTypes, instance.components]));
|
|
23
|
+
yield fs.writeFile('.t4s.contentTypes.json', JSON.stringify([instance.contentTypes, instance.components]));
|
|
22
24
|
const dbSettings = instance.config.get('database.connection');
|
|
23
25
|
//close server to release the db-file
|
|
24
26
|
yield instance.server.httpServer.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oak-digital/types-4-strapi-2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Typescript interface generator for Strapi 4 models",
|
|
5
5
|
"bin": {
|
|
6
6
|
"t4s": "./bin/index.js"
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@typescript-eslint/parser": "^5.33.1",
|
|
29
29
|
"eslint": "^8.22.0",
|
|
30
30
|
"rimraf": "^4.4.1",
|
|
31
|
+
"ts-node": "^10.9.1",
|
|
31
32
|
"typescript": "^4.7.4"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"testtypes": "node ./bin/index.js",
|
|
42
43
|
"lint": "eslint src/",
|
|
43
44
|
"prettier": "prettier --write \"src/**/*.ts\"",
|
|
44
|
-
"t4s": "node ./bin/index.js"
|
|
45
|
+
"t4s": "node ./bin/index.js",
|
|
46
|
+
"testdev": "ts-node ./src/index.ts"
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*]
|
|
4
|
-
indent_style = space
|
|
5
|
-
indent_size = 2
|
|
6
|
-
end_of_line = lf
|
|
7
|
-
charset = utf-8
|
|
8
|
-
trim_trailing_whitespace = true
|
|
9
|
-
insert_final_newline = true
|
|
10
|
-
|
|
11
|
-
[{package.json,*.yml}]
|
|
12
|
-
indent_style = space
|
|
13
|
-
indent_size = 2
|
|
14
|
-
|
|
15
|
-
[*.md]
|
|
16
|
-
trim_trailing_whitespace = false
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# 🚀 Getting started with Strapi
|
|
2
|
-
|
|
3
|
-
Strapi comes with a full featured [Command Line Interface](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html) (CLI) which lets you scaffold and manage your project in seconds.
|
|
4
|
-
|
|
5
|
-
### `develop`
|
|
6
|
-
|
|
7
|
-
Start your Strapi application with autoReload enabled. [Learn more](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-develop)
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
npm run develop
|
|
11
|
-
# or
|
|
12
|
-
yarn develop
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### `start`
|
|
16
|
-
|
|
17
|
-
Start your Strapi application with autoReload disabled. [Learn more](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-start)
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
npm run start
|
|
21
|
-
# or
|
|
22
|
-
yarn start
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### `build`
|
|
26
|
-
|
|
27
|
-
Build your admin panel. [Learn more](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-build)
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
npm run build
|
|
31
|
-
# or
|
|
32
|
-
yarn build
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## ⚙️ Deployment
|
|
36
|
-
|
|
37
|
-
Strapi gives you many possible deployment options for your project. Find the one that suits you on the [deployment section of the documentation](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment.html).
|
|
38
|
-
|
|
39
|
-
## 📚 Learn more
|
|
40
|
-
|
|
41
|
-
- [Resource center](https://strapi.io/resource-center) - Strapi resource center.
|
|
42
|
-
- [Strapi documentation](https://docs.strapi.io) - Official Strapi documentation.
|
|
43
|
-
- [Strapi tutorials](https://strapi.io/tutorials) - List of tutorials made by the core team and the community.
|
|
44
|
-
- [Strapi blog](https://docs.strapi.io) - Official Strapi blog containing articles made by the Strapi team and the community.
|
|
45
|
-
- [Changelog](https://strapi.io/changelog) - Find out about the Strapi product updates, new features and general improvements.
|
|
46
|
-
|
|
47
|
-
Feel free to check out the [Strapi GitHub repository](https://github.com/strapi/strapi). Your feedback and contributions are welcome!
|
|
48
|
-
|
|
49
|
-
## ✨ Community
|
|
50
|
-
|
|
51
|
-
- [Discord](https://discord.strapi.io) - Come chat with the Strapi community including the core team.
|
|
52
|
-
- [Forum](https://forum.strapi.io/) - Place to discuss, ask questions and find answers, show your Strapi project and get feedback or just talk with other Community members.
|
|
53
|
-
- [Awesome Strapi](https://github.com/strapi/awesome-strapi) - A curated list of awesome things related to Strapi.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
<sub>🤫 Psst! [Strapi is hiring](https://strapi.io/careers).</sub>
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
export default ({ env }) => {
|
|
4
|
-
const client = env('DATABASE_CLIENT', 'sqlite');
|
|
5
|
-
|
|
6
|
-
const connections = {
|
|
7
|
-
mysql: {
|
|
8
|
-
connection: {
|
|
9
|
-
connectionString: env('DATABASE_URL'),
|
|
10
|
-
host: env('DATABASE_HOST', 'localhost'),
|
|
11
|
-
port: env.int('DATABASE_PORT', 3306),
|
|
12
|
-
database: env('DATABASE_NAME', 'strapi'),
|
|
13
|
-
user: env('DATABASE_USERNAME', 'strapi'),
|
|
14
|
-
password: env('DATABASE_PASSWORD', 'strapi'),
|
|
15
|
-
ssl: env.bool('DATABASE_SSL', false) && {
|
|
16
|
-
key: env('DATABASE_SSL_KEY', undefined),
|
|
17
|
-
cert: env('DATABASE_SSL_CERT', undefined),
|
|
18
|
-
ca: env('DATABASE_SSL_CA', undefined),
|
|
19
|
-
capath: env('DATABASE_SSL_CAPATH', undefined),
|
|
20
|
-
cipher: env('DATABASE_SSL_CIPHER', undefined),
|
|
21
|
-
rejectUnauthorized: env.bool(
|
|
22
|
-
'DATABASE_SSL_REJECT_UNAUTHORIZED',
|
|
23
|
-
true
|
|
24
|
-
),
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
|
|
28
|
-
},
|
|
29
|
-
mysql2: {
|
|
30
|
-
connection: {
|
|
31
|
-
host: env('DATABASE_HOST', 'localhost'),
|
|
32
|
-
port: env.int('DATABASE_PORT', 3306),
|
|
33
|
-
database: env('DATABASE_NAME', 'strapi'),
|
|
34
|
-
user: env('DATABASE_USERNAME', 'strapi'),
|
|
35
|
-
password: env('DATABASE_PASSWORD', 'strapi'),
|
|
36
|
-
ssl: env.bool('DATABASE_SSL', false) && {
|
|
37
|
-
key: env('DATABASE_SSL_KEY', undefined),
|
|
38
|
-
cert: env('DATABASE_SSL_CERT', undefined),
|
|
39
|
-
ca: env('DATABASE_SSL_CA', undefined),
|
|
40
|
-
capath: env('DATABASE_SSL_CAPATH', undefined),
|
|
41
|
-
cipher: env('DATABASE_SSL_CIPHER', undefined),
|
|
42
|
-
rejectUnauthorized: env.bool(
|
|
43
|
-
'DATABASE_SSL_REJECT_UNAUTHORIZED',
|
|
44
|
-
true
|
|
45
|
-
),
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
|
|
49
|
-
},
|
|
50
|
-
postgres: {
|
|
51
|
-
connection: {
|
|
52
|
-
connectionString: env('DATABASE_URL'),
|
|
53
|
-
host: env('DATABASE_HOST', 'localhost'),
|
|
54
|
-
port: env.int('DATABASE_PORT', 5432),
|
|
55
|
-
database: env('DATABASE_NAME', 'strapi'),
|
|
56
|
-
user: env('DATABASE_USERNAME', 'strapi'),
|
|
57
|
-
password: env('DATABASE_PASSWORD', 'strapi'),
|
|
58
|
-
ssl: env.bool('DATABASE_SSL', false) && {
|
|
59
|
-
key: env('DATABASE_SSL_KEY', undefined),
|
|
60
|
-
cert: env('DATABASE_SSL_CERT', undefined),
|
|
61
|
-
ca: env('DATABASE_SSL_CA', undefined),
|
|
62
|
-
capath: env('DATABASE_SSL_CAPATH', undefined),
|
|
63
|
-
cipher: env('DATABASE_SSL_CIPHER', undefined),
|
|
64
|
-
rejectUnauthorized: env.bool(
|
|
65
|
-
'DATABASE_SSL_REJECT_UNAUTHORIZED',
|
|
66
|
-
true
|
|
67
|
-
),
|
|
68
|
-
},
|
|
69
|
-
schema: env('DATABASE_SCHEMA', 'public'),
|
|
70
|
-
},
|
|
71
|
-
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
|
|
72
|
-
},
|
|
73
|
-
sqlite: {
|
|
74
|
-
connection: {
|
|
75
|
-
filename: path.join(
|
|
76
|
-
__dirname,
|
|
77
|
-
'..',
|
|
78
|
-
'..',
|
|
79
|
-
env('DATABASE_FILENAME', 'data.db')
|
|
80
|
-
),
|
|
81
|
-
},
|
|
82
|
-
useNullAsDefault: true,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
connection: {
|
|
88
|
-
client,
|
|
89
|
-
...connections[client],
|
|
90
|
-
acquireConnectionTimeout: env.int('DATABASE_CONNECTION_TIMEOUT', 60000),
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
};
|
|
File without changes
|
|
Binary file
|