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

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 1 commit
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
Next Next commit
fix: output app version number just like core
  • Loading branch information
KaneFreeman committed Oct 31, 2023
commit 344d1da5e0c6be083ad724ecfdbec393cc7f4487
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
3 changes: 3 additions & 0 deletions packages/app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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
Loading