Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit bf0c5b6

Browse files
authored
fix: output app version number just like core (#962)
1 parent e7dd7bd commit bf0c5b6

File tree

8 files changed

+15
-13
lines changed

8 files changed

+15
-13
lines changed

packages/app/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
'cypress/globals': true,
1616
},
1717
globals: {
18-
STATIC_CMS_CORE_VERSION: false,
18+
STATIC_CMS_APP_VERSION: false,
1919
CMS_ENV: false,
2020
},
2121
rules: {

packages/app/babel.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path');
22

3-
const coreVersion = require('./package.json').version;
3+
const appVersion = require('./package.json').version;
44
const isProduction = process.env.NODE_ENV === 'production';
55
const isTest = process.env.NODE_ENV === 'test';
66
const isESM = process.env.NODE_ENV === 'esm';
@@ -59,7 +59,7 @@ function plugins() {
5959
[
6060
'transform-define',
6161
{
62-
STATIC_CMS_CORE_VERSION: `${coreVersion}`,
62+
STATIC_CMS_APP_VERSION: `${appVersion}`,
6363
},
6464
],
6565
[

packages/app/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const webpack = require('webpack');
33
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
44
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
55
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6+
const pkg = require('./package.json');
67

78
const isProduction = process.env.NODE_ENV === 'production';
89
const devServerPort = parseInt(process.env.STATIC_CMS_DEV_SERVER_PORT || `${8080}`);
@@ -90,6 +91,9 @@ module.exports = {
9091
process: 'process/browser',
9192
Buffer: ['buffer', 'Buffer'],
9293
}),
94+
new webpack.DefinePlugin({
95+
STATIC_CMS_APP_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
96+
}),
9397
].filter(Boolean),
9498
output: {
9599
path: path.resolve(__dirname, 'dist'),

packages/core/src/bootstrap.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ function bootstrap<F extends BaseField = UnknownField>(opts?: {
8181
/**
8282
* Log the version number.
8383
*/
84-
if (typeof STATIC_CMS_CORE_VERSION === 'string') {
84+
if (typeof STATIC_CMS_APP_VERSION === 'string') {
85+
console.info(`[StaticCMS] Using @staticcms/app ${STATIC_CMS_APP_VERSION}`);
86+
} else if (typeof STATIC_CMS_CORE_VERSION === 'string') {
8587
console.info(`[StaticCMS] Using @staticcms/core ${STATIC_CMS_CORE_VERSION}`);
8688
}
8789

packages/core/src/components/ErrorBoundary.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ ${config}
5151

5252
function buildIssueTemplate(config?: Config) {
5353
let version = '';
54-
if (typeof STATIC_CMS_CORE_VERSION === 'string') {
55-
version = `static-cms@${STATIC_CMS_CORE_VERSION}`;
54+
if (typeof STATIC_CMS_APP_VERSION === 'string') {
55+
version = `@staticcms/app@${STATIC_CMS_APP_VERSION}`;
56+
} else if (typeof STATIC_CMS_CORE_VERSION === 'string') {
57+
version = `@staticcms/core@${STATIC_CMS_CORE_VERSION}`;
5658
}
5759
const template = getIssueTemplate(
5860
version,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
declare const STATIC_CMS_CORE_VERSION: string;
2+
declare const STATIC_CMS_APP_VERSION: string;

packages/docs/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = {
1515
jest: true,
1616
},
1717
globals: {
18-
STATIC_CMS_CORE_VERSION: false,
1918
CMS_ENV: false,
2019
},
2120
rules: {

packages/tools/babel.config.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ function plugins() {
5656
if (isESM) {
5757
return [
5858
...defaultPlugins,
59-
[
60-
'transform-define',
61-
{
62-
STATIC_CMS_CORE_VERSION: `${coreVersion}`,
63-
},
64-
],
6559
[
6660
'inline-react-svg',
6761
{

0 commit comments

Comments
 (0)