Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: output app version number just like core #962

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/app/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
'cypress/globals': true,
},
globals: {
STATIC_CMS_CORE_VERSION: false,
STATIC_CMS_APP_VERSION: false,
CMS_ENV: false,
},
rules: {
Expand Down
4 changes: 2 additions & 2 deletions packages/app/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');

const coreVersion = require('./package.json').version;
const appVersion = require('./package.json').version;
const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const isESM = process.env.NODE_ENV === 'esm';
Expand Down Expand Up @@ -59,7 +59,7 @@ function plugins() {
[
'transform-define',
{
STATIC_CMS_CORE_VERSION: `${coreVersion}`,
STATIC_CMS_APP_VERSION: `${appVersion}`,
},
],
[
Expand Down
4 changes: 4 additions & 0 deletions packages/app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const webpack = require('webpack');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const pkg = require('./package.json');

const isProduction = process.env.NODE_ENV === 'production';
const devServerPort = parseInt(process.env.STATIC_CMS_DEV_SERVER_PORT || `${8080}`);
Expand Down Expand Up @@ -90,6 +91,9 @@ module.exports = {
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
new webpack.DefinePlugin({
STATIC_CMS_APP_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
}),
].filter(Boolean),
output: {
path: path.resolve(__dirname, 'dist'),
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ function bootstrap<F extends BaseField = UnknownField>(opts?: {
/**
* Log the version number.
*/
if (typeof STATIC_CMS_CORE_VERSION === 'string') {
if (typeof STATIC_CMS_APP_VERSION === 'string') {
console.info(`[StaticCMS] Using @staticcms/app ${STATIC_CMS_APP_VERSION}`);
} else if (typeof STATIC_CMS_CORE_VERSION === 'string') {
console.info(`[StaticCMS] Using @staticcms/core ${STATIC_CMS_CORE_VERSION}`);
}

Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/components/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ ${config}

function buildIssueTemplate(config?: Config) {
let version = '';
if (typeof STATIC_CMS_CORE_VERSION === 'string') {
version = `static-cms@${STATIC_CMS_CORE_VERSION}`;
if (typeof STATIC_CMS_APP_VERSION === 'string') {
version = `@staticcms/app@${STATIC_CMS_APP_VERSION}`;
} else if (typeof STATIC_CMS_CORE_VERSION === 'string') {
version = `@staticcms/core@${STATIC_CMS_CORE_VERSION}`;
}
const template = getIssueTemplate(
version,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
declare const STATIC_CMS_CORE_VERSION: string;
declare const STATIC_CMS_APP_VERSION: string;
1 change: 0 additions & 1 deletion packages/docs/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module.exports = {
jest: true,
},
globals: {
STATIC_CMS_CORE_VERSION: false,
CMS_ENV: false,
},
rules: {
Expand Down
6 changes: 0 additions & 6 deletions packages/tools/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ function plugins() {
if (isESM) {
return [
...defaultPlugins,
[
'transform-define',
{
STATIC_CMS_CORE_VERSION: `${coreVersion}`,
},
],
[
'inline-react-svg',
{
Expand Down