`externalSchematics` should install packages locally when they are no present in the `node_modules`
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 38/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- angular, typescript
- 領域
- cli
研究方向
從 @angular-devkit/schematics 中的 externalSchematic 函式以及 packages/angular/pwa/pwa/index.ts 中參照的呼叫開始。追蹤外部套件在 node_modules 中不存在時如何解析,接著判斷應如何將安裝整合到該流程中。當無法使用的外部 schematic 套件完成安裝且 schematic 成功執行時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
🚀 Feature request
Command (mark with an x)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- lint
- extract-i18n
- run
- config
- help
- version
- doc
- other
Description
when creating own schematics, they can make use of other schematics by calling the externalSchematic function provided by the @angular-devkit/schematics collection.
To call an external schematic, the function can be used like this:
options = {};
externalSchematic('my-schematic-package', 'my-schematic-name', options);
But to execute an external schematic package it has to be part of the node_modules. Internally the CLI uses the function for example for calling the PWA schematic. This won't be problematic as is already installed as part of the @angular/schematics package and in fact it's part of the node_modules.
Once you'll try to install an external schematic which isn't already available in the node_modules the schematic fails.
A workaround is to manually integrate an installation procedure first and then call the function like this:
export const installNpmPackage = (
context: SchematicContext,
packageName: string,
): Promise<void> => {
return new Promise<void>((resolve) => {
context.logger.info(
`📦 Installing package '${packageName}' for external schematic setup...`,
);
const spawnOptions: SpawnOptions = { stdio: 'inherit' };
spawn('npm', ['install', packageName], spawnOptions).on(
'close',
(code: number) => {
if (code === 0) {
context.logger.info(
`✅ '${packageName}' package installed successfully`,
);
resolve();
} else {
const errorMessage = `❌ installation of '${packageName}' package failed`;
context.logger.error(errorMessage);
throw new Error();
}
},
);
});
};
const packageName = '@briebug/cypress-schematic';
await installNpmPackage(context, packageName);
return externalSchematic(packageName, 'ng-add', {
removeProtractor: true,
addCypressTestScripts: true,
});
Describe the solution you'd like
It would be great to integrate the installation process for a package that's not present in the node_modules in the externalSchematic function.
Describe alternatives you've considered
- 主要語言
- TypeScript
- 星號
- 27k
- 分支
- 11.8k
- 平均合併
- 16 小時 35 分鐘
- 30 天內合併 PR
- 176
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
angular/angular-cli 的其他 Issue
-
area: @angular/build gemini-triaged
難度 2/5 1-3 小時 新手友好度 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
難度 2/5 1-3 小時 新手友好度 72/100
angular/angular-cli#33055 · 1 則留言 · 3 個 reaction ·
-
area: @angular/build gemini-triaged
難度 4/5 3-5 天 新手友好度 72/100
angular/angular-cli#34137 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 已指派 1 人 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 已指派 1 人 ·
查看 angular/angular-cli 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
ontola/atomic-server#1625 ·
-
bug
難度 2/5 1-3 小時 新手友好度 70/100
melgarafael/DeskcommCRM#1451 ·
-
難度 1/5 1 小時以內 新手友好度 82/100
-
bug via-triage
難度 2/5 1-3 小時 新手友好度 78/100
-
bot:ai-assisted component:compact-js status:untriaged
難度 2/5 1-3 小時 新手友好度 84/100
midnightntwrk/midnight-sdk#403 ·