Skip to content

Commit 1c5fae4

Browse files
authored
feat: Add deno as a package manager (#905)
* Add deno to package-manager utils * Include deno in sourcemap tests * Add a registry option to the PackageManager interface * Add force flag to Deno * Include the registry in the installArgs * Add try catch in deno detect() * Remove deno lock array * Add trycatch to all package managers * Add an extra keydown in the tests * Add entry in changelog * Fix bad find and replace * Adjust the order of the package managers * Oops missed pnpm
1 parent 0d6c3d6 commit 1c5fae4

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- feat: add option to ignore git changes ([#898](https://github.com/getsentry/sentry-wizard/pull/898))
1515
- fix(apple): Add additional types to `xcode.d.ts` ([#900](https://github.com/getsentry/sentry-wizard/pull/900))
1616
- fix: enable debug logs for option `--debug` ([#902](https://github.com/getsentry/sentry-wizard/pull/902))
17+
- feat: Add `deno` as a package manager ([#905](https://github.com/getsentry/sentry-wizard/pull/905))
1718

1819
## 4.5.0
1920

src/utils/clack/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@ export async function installPackage({
411411
await new Promise<void>((resolve, reject) => {
412412
const installArgs = [
413413
pkgManager.installCommand,
414-
packageName,
414+
pkgManager.registry
415+
? `${pkgManager.registry}:${packageName}`
416+
: packageName,
415417
...(pkgManager.flags ? pkgManager.flags.split(' ') : []),
416418
...(forceInstall ? [pkgManager.forceInstallFlag] : []),
417419
];

src/utils/package-manager.ts

+52-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface PackageManager {
1414
runScriptCommand: string;
1515
flags: string;
1616
forceInstallFlag: string;
17+
registry?: string;
1718
detect: () => boolean;
1819
addOverride: (pkgName: string, pkgVersion: string) => Promise<void>;
1920
}
@@ -27,9 +28,42 @@ export const BUN: PackageManager = {
2728
flags: '',
2829
forceInstallFlag: '--force',
2930
detect: () =>
30-
['bun.lockb', 'bun.lock'].some((lockFile) =>
31-
fs.existsSync(path.join(process.cwd(), lockFile)),
32-
),
31+
['bun.lockb', 'bun.lock'].some((lockFile) => {
32+
try {
33+
return fs.existsSync(path.join(process.cwd(), lockFile));
34+
} catch (e) {
35+
return false;
36+
}
37+
}),
38+
addOverride: async (pkgName, pkgVersion): Promise<void> => {
39+
const packageDotJson = await getPackageDotJson();
40+
const overrides = packageDotJson.overrides || {};
41+
42+
await updatePackageDotJson({
43+
...packageDotJson,
44+
overrides: {
45+
...overrides,
46+
[pkgName]: pkgVersion,
47+
},
48+
});
49+
},
50+
};
51+
export const DENO: PackageManager = {
52+
name: 'deno',
53+
label: 'Deno',
54+
installCommand: 'install',
55+
buildCommand: 'deno task build',
56+
runScriptCommand: 'deno task',
57+
flags: '',
58+
forceInstallFlag: '--force',
59+
registry: 'npm',
60+
detect: () => {
61+
try {
62+
return fs.existsSync(path.join(process.cwd(), 'deno.lock'));
63+
} catch (e) {
64+
return false;
65+
}
66+
},
3367
addOverride: async (pkgName, pkgVersion): Promise<void> => {
3468
const packageDotJson = await getPackageDotJson();
3569
const overrides = packageDotJson.overrides || {};
@@ -114,7 +148,13 @@ export const PNPM: PackageManager = {
114148
runScriptCommand: 'pnpm',
115149
flags: '--ignore-workspace-root-check',
116150
forceInstallFlag: '--force',
117-
detect: () => fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml')),
151+
detect: () => {
152+
try {
153+
return fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'));
154+
} catch (e) {
155+
return false;
156+
}
157+
},
118158
addOverride: async (pkgName, pkgVersion): Promise<void> => {
119159
const packageDotJson = await getPackageDotJson();
120160
const pnpm = packageDotJson.pnpm || {};
@@ -140,7 +180,13 @@ export const NPM: PackageManager = {
140180
runScriptCommand: 'npm run',
141181
flags: '',
142182
forceInstallFlag: '--force',
143-
detect: () => fs.existsSync(path.join(process.cwd(), 'package-lock.json')),
183+
detect: () => {
184+
try {
185+
return fs.existsSync(path.join(process.cwd(), 'package-lock.json'));
186+
} catch (e) {
187+
return false;
188+
}
189+
},
144190
addOverride: async (pkgName, pkgVersion): Promise<void> => {
145191
const packageDotJson = await getPackageDotJson();
146192
const overrides = packageDotJson.overrides || {};
@@ -155,7 +201,7 @@ export const NPM: PackageManager = {
155201
},
156202
};
157203

158-
export const packageManagers = [BUN, YARN_V1, YARN_V2, PNPM, NPM];
204+
export const packageManagers = [NPM, YARN_V1, YARN_V2, PNPM, BUN, DENO];
159205

160206
/**
161207
* Exported only for testing.

test/sourcemaps/tools/sentry-cli.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe('addSentryCommandToBuildCommand', () => {
4141
packageManagerHelpers.YARN_V1,
4242
packageManagerHelpers.YARN_V2,
4343
packageManagerHelpers.BUN,
44+
packageManagerHelpers.DENO,
4445
],
4546
])('adds the cli command to the script command (%s)', async (_, pacMan) => {
4647
jest

0 commit comments

Comments
 (0)