Skip to content

Commit 61ce455

Browse files
committed
feat(@angular/cli): add support for the nub package manager
Recognize nub (https://nubjs.com) as a supported package manager. nub is pnpm-CLI-compatible and writes a pnpm-v9-format lockfile (nub.lock), so its handling mirrors pnpm throughout. - Add a `nub` descriptor to SUPPORTED_PACKAGE_MANAGERS (cloned from pnpm, with `binary: 'nub'` and `lockfiles: ['nub.lock']`) and to PACKAGE_MANAGER_PRECEDENCE. Lockfile discovery is data-driven off the descriptor, so `nub.lock` is now detected automatically. - Add a `nub` entry to the schematics package-manager executor map (installAll: install, installPackage: add), which previously threw UnknownPackageManagerException for nub. - Add `nub` to the packageManager enum in the workspace, ng-new, and schematics-CLI schemas, and to the user-agent allowlist in the `npm create @angular` shim.
1 parent 2462709 commit 61ce455

8 files changed

Lines changed: 45 additions & 7 deletions

File tree

packages/angular/cli/lib/config/workspace-schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"packageManager": {
4848
"description": "Specify which package manager tool to use.",
4949
"type": "string",
50-
"enum": ["npm", "yarn", "pnpm", "bun"]
50+
"enum": ["npm", "yarn", "pnpm", "bun", "nub"]
5151
},
5252
"warnings": {
5353
"description": "Control CLI specific console warnings",
@@ -101,7 +101,7 @@
101101
"packageManager": {
102102
"description": "Specify which package manager tool to use.",
103103
"type": "string",
104-
"enum": ["npm", "yarn", "pnpm", "bun"]
104+
"enum": ["npm", "yarn", "pnpm", "bun", "nub"]
105105
},
106106
"warnings": {
107107
"description": "Control CLI specific console warnings",

packages/angular/cli/src/package-managers/package-manager-descriptor.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,37 @@ export const SUPPORTED_PACKAGE_MANAGERS = {
281281
},
282282
isNotFound: isKnownNotFound,
283283
},
284+
nub: {
285+
// nub is pnpm-CLI-compatible, so its descriptor mirrors pnpm's aside from
286+
// the binary name and the pnpm-v9-format lockfile it writes (`nub.lock`).
287+
binary: 'nub',
288+
lockfiles: ['nub.lock'],
289+
addCommand: 'add',
290+
installCommand: ['install'],
291+
forceFlag: '--force',
292+
saveExactFlag: '--save-exact',
293+
saveTildeFlag: '--save-tilde',
294+
saveDevFlag: '--save-dev',
295+
noLockfileFlag: '--no-lockfile',
296+
ignoreScriptsFlag: '--ignore-scripts',
297+
ignorePeerDependenciesFlag: '--strict-peer-dependencies=false',
298+
configFiles: ['.npmrc'],
299+
getRegistryOptions: (registry: string) => ({ args: ['--registry', registry] }),
300+
versionCommand: ['--version'],
301+
listDependenciesCommand: ['list', '--depth=0', '--json'],
302+
getReleaseAgeConfigCommand: ['config', 'get', 'minimum-release-age'],
303+
getPackageNameCommand: ['pkg', 'get', 'name'],
304+
getManifestCommand: ['view', '--json'],
305+
viewCommandFieldArgFormatter: (fields) => [...fields],
306+
outputParsers: {
307+
listDependencies: parseNpmLikeDependencies,
308+
getRegistryManifest: parseNpmLikeManifest,
309+
getRegistryMetadata: parseNpmLikeMetadata,
310+
getError: parseNpmLikeError,
311+
getReleaseAge: parsePnpmReleaseAge,
312+
},
313+
isNotFound: isKnownNotFound,
314+
},
284315
bun: {
285316
binary: 'bun',
286317
lockfiles: ['bun.lockb', 'bun.lock'],
@@ -346,6 +377,7 @@ export const SUPPORTED_PACKAGE_MANAGERS = {
346377
*/
347378
export const PACKAGE_MANAGER_PRECEDENCE: readonly PackageManagerName[] = [
348379
'pnpm',
380+
'nub',
349381
'yarn',
350382
'bun',
351383
'npm',

packages/angular/create/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const hasPackageManagerArg = args.some((a) => a.startsWith('--package-manager'))
1717
if (!hasPackageManagerArg) {
1818
// Ex: yarn/1.22.18 npm/? node/v16.15.1 linux x64
1919
const packageManager = process.env['npm_config_user_agent']?.split('/')[0];
20-
if (packageManager && ['npm', 'pnpm', 'yarn', 'bun'].includes(packageManager)) {
20+
if (packageManager && ['npm', 'pnpm', 'yarn', 'bun', 'nub'].includes(packageManager)) {
2121
args.push('--package-manager', packageManager);
2222
}
2323
}

packages/angular_devkit/schematics/tasks/package-manager/executor.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ const packageManagers: { [name: string]: PackageManagerProfile } = {
4545
installPackage: 'install',
4646
},
4747
},
48+
'nub': {
49+
commands: {
50+
installAll: 'install',
51+
installPackage: 'add',
52+
},
53+
},
4854
};
4955

5056
export class UnknownPackageManagerException extends BaseException {

packages/angular_devkit/schematics_cli/blank/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"packageManager": {
1616
"description": "The package manager used to install dependencies.",
1717
"type": "string",
18-
"enum": ["npm", "yarn", "pnpm", "bun"],
18+
"enum": ["npm", "yarn", "pnpm", "bun", "nub"],
1919
"default": "npm"
2020
},
2121
"author": {

packages/angular_devkit/schematics_cli/schematic/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"packageManager": {
1616
"description": "The package manager used to install dependencies.",
1717
"type": "string",
18-
"enum": ["npm", "yarn", "pnpm", "bun"],
18+
"enum": ["npm", "yarn", "pnpm", "bun", "nub"],
1919
"default": "npm"
2020
}
2121
},

packages/schematics/angular/ng-new/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"packageManager": {
133133
"description": "The package manager used to install dependencies.",
134134
"type": "string",
135-
"enum": ["npm", "yarn", "pnpm", "bun"]
135+
"enum": ["npm", "yarn", "pnpm", "bun", "nub"]
136136
},
137137
"standalone": {
138138
"description": "Creates an application based upon the standalone API, without NgModules.",

packages/schematics/angular/workspace/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"packageManager": {
4141
"description": "The package manager to use for installing dependencies.",
4242
"type": "string",
43-
"enum": ["npm", "yarn", "pnpm", "bun"],
43+
"enum": ["npm", "yarn", "pnpm", "bun", "nub"],
4444
"$default": {
4545
"$source": "packageManager"
4646
}

0 commit comments

Comments
 (0)