@akinon/next 1.21.0-rc.5 → 1.21.0-rc.6
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 +6 -0
- package/bin/pz-install-plugins.js +59 -27
- package/package.json +2 -2
- package/sentry/index.ts +20 -14
- package/types/index.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,39 +1,71 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
1
|
const fs = require('fs');
|
|
4
2
|
const path = require('path');
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
function findBaseDir() {
|
|
6
|
+
const insideNodeModules = __dirname.includes('node_modules');
|
|
7
|
+
return insideNodeModules
|
|
8
|
+
? process.cwd()
|
|
9
|
+
: path.resolve(__dirname, '../../../apps/projectzeronext');
|
|
10
|
+
}
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
const BASE_DIR = findBaseDir();
|
|
13
|
+
const getFullPath = (relativePath) => path.join(BASE_DIR, relativePath);
|
|
14
|
+
|
|
15
|
+
const packageJsonPath = getFullPath('package.json');
|
|
16
|
+
let packageJson;
|
|
10
17
|
|
|
11
18
|
try {
|
|
12
|
-
|
|
19
|
+
packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
13
20
|
} catch (error) {
|
|
14
|
-
console.error('
|
|
15
|
-
process.exit(
|
|
21
|
+
console.error('Error reading package.json:', error);
|
|
22
|
+
process.exit(1);
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
const pluginsJsPath = getFullPath('src/plugins.js');
|
|
26
|
+
let installedPlugins;
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
installedPlugins = require(pluginsJsPath);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error('Error loading installed plugins:', error);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
19
34
|
|
|
20
|
-
|
|
21
|
-
.filter((p) => plugins?.includes(p))
|
|
22
|
-
.forEach((name) => {
|
|
23
|
-
installCmd.push(`@akinon/${name}`);
|
|
24
|
-
});
|
|
35
|
+
const protectedPackages = ['@akinon/next', 'next'];
|
|
25
36
|
|
|
26
|
-
|
|
37
|
+
const pluginsToRemove = Object.keys(packageJson.dependencies || {}).filter(
|
|
38
|
+
(dep) =>
|
|
39
|
+
dep.startsWith('@akinon/') &&
|
|
40
|
+
installedPlugins.includes(dep.replace('@akinon/', '')) &&
|
|
41
|
+
!protectedPackages.includes(dep)
|
|
42
|
+
);
|
|
27
43
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
44
|
+
pluginsToRemove.forEach((plugin) => {
|
|
45
|
+
try {
|
|
46
|
+
execSync(`yarn remove ${plugin}`, { stdio: 'inherit', cwd: BASE_DIR });
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.warn(
|
|
49
|
+
`Warning: Could not remove ${plugin}. It may not have been installed.`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
31
53
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
installedPlugins.forEach((plugin) => {
|
|
55
|
+
const packageName = `@akinon/${plugin}`;
|
|
56
|
+
if (
|
|
57
|
+
!Object.keys(packageJson.dependencies || {}).includes(packageName) &&
|
|
58
|
+
!protectedPackages.includes(packageName)
|
|
59
|
+
) {
|
|
60
|
+
try {
|
|
61
|
+
const version = packageJson.dependencies['@akinon/next'].replace('^', '');
|
|
62
|
+
const command = `yarn add ${packageName}@${version} --exact --ignore-scripts`;
|
|
63
|
+
execSync(command, { stdio: 'inherit', cwd: BASE_DIR });
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.warn(
|
|
66
|
+
'\n\x1b[33m%s\x1b[0m',
|
|
67
|
+
`Error adding ${packageName}: ${error}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.21.0-rc.
|
|
4
|
+
"version": "1.21.0-rc.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
33
33
|
"@typescript-eslint/parser": "6.7.4",
|
|
34
34
|
"eslint": "^8.14.0",
|
|
35
|
-
"@akinon/eslint-plugin-projectzero": "1.21.0-rc.
|
|
35
|
+
"@akinon/eslint-plugin-projectzero": "1.21.0-rc.6",
|
|
36
36
|
"eslint-config-prettier": "8.5.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/sentry/index.ts
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/nextjs';
|
|
2
|
+
import settings from 'settings';
|
|
2
3
|
|
|
3
4
|
const SENTRY_DSN: string =
|
|
4
|
-
|
|
5
|
+
settings.sentryDsn ||
|
|
6
|
+
process.env.SENTRY_DSN ||
|
|
7
|
+
process.env.NEXT_PUBLIC_SENTRY_DSN;
|
|
5
8
|
|
|
6
9
|
export const initSentry = (
|
|
7
10
|
type: 'Server' | 'Client' | 'Edge',
|
|
8
|
-
options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {
|
|
11
|
+
options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {
|
|
12
|
+
dsn: SENTRY_DSN,
|
|
13
|
+
integrations: [],
|
|
14
|
+
tracesSampleRate: 1.0
|
|
15
|
+
}
|
|
9
16
|
) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// TODO: Remove Zero Project DSN
|
|
13
|
-
|
|
14
|
-
Sentry.init({
|
|
15
|
-
dsn:
|
|
16
|
-
SENTRY_DSN ||
|
|
17
|
-
'https://d8558ef8997543deacf376c7d8d7cf4b@o64293.ingest.sentry.io/4504338423742464',
|
|
17
|
+
const initOptions = {
|
|
18
|
+
...options,
|
|
18
19
|
initialScope: {
|
|
19
20
|
tags: {
|
|
21
|
+
...((
|
|
22
|
+
options.initialScope as {
|
|
23
|
+
tags?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
)?.tags ?? {}),
|
|
20
26
|
APP_TYPE: 'ProjectZeroNext',
|
|
21
27
|
TYPE: type
|
|
22
28
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
Sentry.init(initOptions);
|
|
27
33
|
};
|
package/types/index.ts
CHANGED
|
@@ -71,6 +71,12 @@ export interface Currency {
|
|
|
71
71
|
|
|
72
72
|
export interface Settings {
|
|
73
73
|
commerceUrl: string;
|
|
74
|
+
/**
|
|
75
|
+
* This option allows you to track Sentry events on the client side, in addition to server and edge environments.
|
|
76
|
+
*
|
|
77
|
+
* It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
|
|
78
|
+
*/
|
|
79
|
+
sentryDsn?: string;
|
|
74
80
|
redis: {
|
|
75
81
|
defaultExpirationTime: number;
|
|
76
82
|
};
|