diff --git a/.env b/.env new file mode 100644 index 00000000..083c815f --- /dev/null +++ b/.env @@ -0,0 +1 @@ +NODE_ENV=development \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 78996ba8..1f0ba8a7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 cache: 'npm' - uses: actions/cache@v2 with: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a5a7d489..5748494c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - name: setup node uses: actions/setup-node@v1 with: - node-version: 16 + node-version: 18 - name: get version run: echo "TAG_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: create release @@ -42,7 +42,7 @@ jobs: - name: setup node uses: actions/setup-node@v1 with: - node-version: 16 + node-version: 18 - name: install Rust stable uses: actions-rs/toolchain@v1 with: diff --git a/cloudtower-api-doc/docusaurus.config.js b/cloudtower-api-doc/docusaurus.config.js index ab10df57..afd078ef 100644 --- a/cloudtower-api-doc/docusaurus.config.js +++ b/cloudtower-api-doc/docusaurus.config.js @@ -5,16 +5,6 @@ const lightCodeTheme = require("prism-react-renderer/themes/github"); const darkCodeTheme = require("prism-react-renderer/themes/dracula"); const webpack = require("webpack"); -if(!process.env.TAURI_ENV) { - process.env = new Proxy(process.env, { - get(target, prop) { - if(prop === 'NODE_ENV') { - return 'development' - } - return typeof target[prop] === 'function' ? target[prop].bind(target) : target[prop] - } - }) -} /** @type {import('@docusaurus/types').Config} */ const config = { @@ -89,6 +79,7 @@ const config = { }; }, 'docusaurus-plugin-sass', + 'docusaurus2-dotenv' ], themeConfig: diff --git a/cloudtower-api-doc/swagger/App.tsx b/cloudtower-api-doc/swagger/App.tsx index 6d1ddcbe..41e1e7c2 100644 --- a/cloudtower-api-doc/swagger/App.tsx +++ b/cloudtower-api-doc/swagger/App.tsx @@ -82,13 +82,16 @@ const App: React.FC = () => { const specRef = useRef(spec); useEffect(() => { const lastVersion = specMap[version] ? version : Object.keys(specMap)[0]; - const swaggerSpec: ISpec = _.cloneDeep(specMap[lastVersion]); - setRawSpec(swaggerSpec); - i18next.changeLanguage(i18n.currentLocale); - const newSpec = splitSchema( - wrapSpecWithI18n(swaggerSpec, i18n.currentLocale, version) - ); - setSpec(newSpec); + specMap[lastVersion].then(data => { + const swaggerSpec: ISpec = _.cloneDeep(data.default); + setRawSpec(swaggerSpec); + i18next.changeLanguage(i18n.currentLocale); + const newSpec = splitSchema( + wrapSpecWithI18n(swaggerSpec, i18n.currentLocale, version) + ); + setSpec(newSpec); + }) + }, [version, i18n.currentLocale]); useEffect(() => { diff --git a/cloudtower-api-doc/swagger/utils/swagger.ts b/cloudtower-api-doc/swagger/utils/swagger.ts index e7944be9..c4857390 100644 --- a/cloudtower-api-doc/swagger/utils/swagger.ts +++ b/cloudtower-api-doc/swagger/utils/swagger.ts @@ -1,40 +1,22 @@ import { OpenAPIV3 } from 'openapi-types'; -import swaggerSpec1_8 from "../../static/specs/1.8.0-swagger.json"; -import swaggerSpec1_9 from '../../static/specs/1.9.0-swagger.json'; -import swaggerSpec1_10 from '../../static/specs/1.10.0-swagger.json'; -import swaggerSpec2_0 from '../../static/specs/2.0.0-swagger.json'; -import swaggerSpec2_1 from '../../static/specs/2.1.0-swagger.json'; -import swaggerSpec2_2 from '../../static/specs/2.2.0-swagger.json'; -import swaggerSpec2_3 from '../../static/specs/2.3.0-swagger.json'; -import swaggerSpec2_4 from '../../static/specs/2.4.0-swagger.json'; -import swaggerSpec2_5 from '../../static/specs/2.5.0-swagger.json'; -import swaggerSpec2_6 from '../../static/specs/2.6.0-swagger.json'; -import swaggerSpec2_7 from '../../static/specs/2.7.0-swagger.json'; -import swaggerSpec2_8 from '../../static/specs/2.8.0-swagger.json'; -import swaggerSpec3_0 from '../../static/specs/3.0.0-swagger.json'; -import swaggerSpec3_1 from '../../static/specs/3.1.0-swagger.json'; -import swaggerSpec3_2 from '../../static/specs/3.2.0-swagger.json'; -import swaggerSpec3_3 from '../../static/specs/3.3.0-swagger.json'; - - export const specMap = { - '3.3.0': swaggerSpec3_3, - '3.2.0': swaggerSpec3_2, - '3.1.0': swaggerSpec3_1, - '3.0.0': swaggerSpec3_0, - '2.8.0': swaggerSpec2_8, - '2.7.0': swaggerSpec2_7, - '2.6.0': swaggerSpec2_6, - '2.5.0': swaggerSpec2_5, - '2.4.0': swaggerSpec2_4, - '2.3.0': swaggerSpec2_3, - '2.2.0': swaggerSpec2_2, - '2.1.0': swaggerSpec2_1, - '2.0.0': swaggerSpec2_0, - '1.10.0': swaggerSpec1_10, - '1.9.0': swaggerSpec1_9, - '1.8.0': swaggerSpec1_8, + '3.3.0': import('../../static/specs/3.3.0-swagger.json'), + '3.2.0': import('../../static/specs/3.2.0-swagger.json'), + '3.1.0': import('../../static/specs/3.1.0-swagger.json'), + '3.0.0': import('../../static/specs/3.0.0-swagger.json'), + '2.8.0': import('../../static/specs/2.8.0-swagger.json'), + '2.7.0': import('../../static/specs/2.7.0-swagger.json'), + '2.6.0': import('../../static/specs/2.6.0-swagger.json'), + '2.5.0': import('../../static/specs/2.5.0-swagger.json'), + '2.4.0': import('../../static/specs/2.4.0-swagger.json'), + '2.3.0': import('../../static/specs/2.3.0-swagger.json'), + '2.2.0': import('../../static/specs/2.2.0-swagger.json'), + '2.1.0': import('../../static/specs/2.1.0-swagger.json'), + '2.0.0': import('../../static/specs/2.0.0-swagger.json'), + '1.10.0': import('../../static/specs/1.10.0-swagger.json'), + '1.9.0': import('../../static/specs/1.9.0-swagger.json'), + '1.8.0': import('../../static/specs/1.8.0-swagger.json'), } diff --git a/package.json b/package.json index 501ef3ea..d1bc94a1 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "commander": "^11.0.0", "cross-env": "^7.0.3", "docusaurus-plugin-sass": "^0.2.3", + "docusaurus2-dotenv": "^1.4.0", "fs-extra": "^10.0.1", "graphql": "^16.3.0", "i18next": "^21.3.1", diff --git a/yarn.lock b/yarn.lock index 8857b8a2..2d0f8f14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6742,6 +6742,7 @@ __metadata: core-js: ^3.21.1 cross-env: ^7.0.3 docusaurus-plugin-sass: ^0.2.3 + docusaurus2-dotenv: ^1.4.0 fs-extra: ^10.0.1 graphql: ^16.3.0 httpsnippet: ^2.0.0 @@ -7869,6 +7870,15 @@ __metadata: languageName: node linkType: hard +"docusaurus2-dotenv@npm:^1.4.0": + version: 1.4.0 + resolution: "docusaurus2-dotenv@npm:1.4.0" + dependencies: + dotenv-webpack: 1.7.0 + checksum: 5589ab71fe4de7bf53ebca47b6763d4dc37708df8171dd515a0464c4509f0bcc78d0cc823a31f32bcd0ba28873d7f4c946a47e61f9ad26104a2eac57f9f29224 + languageName: node + linkType: hard + "dom-converter@npm:^0.2.0": version: 0.2.0 resolution: "dom-converter@npm:0.2.0" @@ -8023,6 +8033,33 @@ __metadata: languageName: node linkType: hard +"dotenv-defaults@npm:^1.0.2": + version: 1.1.1 + resolution: "dotenv-defaults@npm:1.1.1" + dependencies: + dotenv: ^6.2.0 + checksum: 623749be33fc30b686ff910522e4c222a08aa4d0011ff40b4354baee5db796f00eb42e818425667db2ffe9d8d2ae5f597a5e5b066b797f7aab9e06e515088fd6 + languageName: node + linkType: hard + +"dotenv-webpack@npm:1.7.0": + version: 1.7.0 + resolution: "dotenv-webpack@npm:1.7.0" + dependencies: + dotenv-defaults: ^1.0.2 + peerDependencies: + webpack: ^1 || ^2 || ^3 || ^4 + checksum: b5039955cff5961dae690bc779b928ac3ec637ba4223032c62c7bb4d034756d8074aaf4990c2199b87806ce51bf73019349c9930dd8872062427dcd492b37bb3 + languageName: node + linkType: hard + +"dotenv@npm:^6.2.0": + version: 6.2.0 + resolution: "dotenv@npm:6.2.0" + checksum: d4aa189741ff45553038b0436dfdb79143c29760d3481b4b19d9f1c59fb8cc69190ab83674e07b32b3dd2ae477579619cde9f7586ea82086151dbbac5626c54c + languageName: node + linkType: hard + "duplexer3@npm:^0.1.4": version: 0.1.4 resolution: "duplexer3@npm:0.1.4"