@akinon/projectzero 1.24.0 → 1.25.0-rc.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @akinon/projectzero
2
2
 
3
+ ## 1.25.0-rc.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 197d602: ZERO-2459: Warn if akinon-next version is not up to date
8
+
3
9
  ## 1.24.0
4
10
 
5
11
  ## 1.23.0
@@ -1,6 +1,7 @@
1
1
  import * as fs from 'fs';
2
2
  import path from 'path';
3
3
  import { execSync } from 'child_process';
4
+ import semver from 'semver';
4
5
 
5
6
  const Prompt = require('prompt-checkbox');
6
7
 
@@ -71,7 +72,42 @@ const definedPlugins = [
71
72
  }
72
73
  ];
73
74
 
75
+ interface PackageInfo {
76
+ 'dist-tags': {
77
+ latest: string;
78
+ };
79
+ }
80
+
81
+ interface PackageJson {
82
+ dependencies: {
83
+ [key: string]: string;
84
+ };
85
+ }
86
+
87
+ async function checkVersion(pkg: PackageJson) {
88
+ const packageName = '@akinon/next';
89
+ const registryUrl = `https://registry.npmjs.org/${packageName}`;
90
+
91
+ try {
92
+ const response = await fetch(registryUrl);
93
+ const pkgInfo = (await response.json()) as PackageInfo;
94
+ const latestVersion = pkgInfo['dist-tags'].latest;
95
+
96
+ if (!semver.satisfies(pkg.dependencies['@akinon/next'], latestVersion)) {
97
+ console.warn(
98
+ `\x1b[43mWarning: The "${packageName}" package is currently at version ${pkg.dependencies['@akinon/next']}. Please upgrade it to the latest version (${latestVersion}) to ensure plugin compatibility.`,
99
+ '\x1b[0m\n'
100
+ );
101
+ }
102
+ } catch (error: any) {
103
+ console.error(`\x1b[41mError: ${error?.message}`, '\x1b[0m\n');
104
+ }
105
+ }
106
+
74
107
  export default async () => {
108
+ const pkg: PackageJson = require(path.resolve(rootDir, './package.json'));
109
+ await checkVersion(pkg);
110
+
75
111
  const prompt = new Prompt({
76
112
  name: 'plugins',
77
113
  message: 'Please check/uncheck plugins to install/uninstall.',
@@ -38,14 +38,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  const fs = __importStar(require("fs"));
39
39
  const path_1 = __importDefault(require("path"));
40
40
  const child_process_1 = require("child_process");
41
+ const semver_1 = __importDefault(require("semver"));
41
42
  const Prompt = require('prompt-checkbox');
42
43
  const rootDir = path_1.default.resolve(process.cwd());
43
- const pluginsFilePath = path_1.default.resolve(rootDir, './packages/akinon-next/plugins.js');
44
+ function findPluginsFilePath() {
45
+ const option1 = path_1.default.resolve(rootDir, './src/plugins.js');
46
+ const option2 = path_1.default.resolve(rootDir, './packages/akinon-next/plugins.js');
47
+ if (fs.existsSync(option1)) {
48
+ return option1;
49
+ }
50
+ else if (fs.existsSync(option2)) {
51
+ return option2;
52
+ }
53
+ else {
54
+ throw new Error('plugins.js was not found in either of the expected locations.');
55
+ }
56
+ }
57
+ const pluginsFilePath = findPluginsFilePath();
44
58
  let installedPlugins = [];
45
59
  try {
46
- installedPlugins = require(path_1.default.resolve(rootDir, './packages/akinon-next/plugins.js'));
60
+ installedPlugins = require(pluginsFilePath);
61
+ }
62
+ catch (error) {
63
+ console.error('Error loading installed plugins:', error);
64
+ process.exit(1);
47
65
  }
48
- catch (error) { }
49
66
  const definedPlugins = [
50
67
  {
51
68
  name: 'Basket Gift Pack',
@@ -84,7 +101,26 @@ const definedPlugins = [
84
101
  value: 'pz-credit-payment'
85
102
  }
86
103
  ];
104
+ function checkVersion(pkg) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ const packageName = '@akinon/next';
107
+ const registryUrl = `https://registry.npmjs.org/${packageName}`;
108
+ try {
109
+ const response = yield fetch(registryUrl);
110
+ const pkgInfo = (yield response.json());
111
+ const latestVersion = pkgInfo['dist-tags'].latest;
112
+ if (!semver_1.default.satisfies(pkg.dependencies['@akinon/next'], latestVersion)) {
113
+ console.warn(`\x1b[43mWarning: The "${packageName}" package is currently at version ${pkg.dependencies['@akinon/next']}. Please upgrade it to the latest version (${latestVersion}) to ensure plugin compatibility.`, '\x1b[0m\n');
114
+ }
115
+ }
116
+ catch (error) {
117
+ console.error(`\x1b[41mError: ${error === null || error === void 0 ? void 0 : error.message}`, '\x1b[0m\n');
118
+ }
119
+ });
120
+ }
87
121
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
122
+ const pkg = require(path_1.default.resolve(rootDir, './package.json'));
123
+ yield checkVersion(pkg);
88
124
  const prompt = new Prompt({
89
125
  name: 'plugins',
90
126
  message: 'Please check/uncheck plugins to install/uninstall.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "1.24.0",
3
+ "version": "1.25.0-rc.0",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {
@@ -15,6 +15,7 @@
15
15
  "license": "ISC",
16
16
  "devDependencies": {
17
17
  "@types/node": "^18.8.0",
18
+ "@types/semver": "7.5.8",
18
19
  "@types/temp": "0.9.4"
19
20
  },
20
21
  "dependencies": {