-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(@angular/create): add support for yarn create
and npm init
#23492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright Google Inc. All Rights Reserved. | ||
# | ||
# Use of this source code is governed by an MIT-style license that can be | ||
# found in the LICENSE file at https://angular.io/license | ||
|
||
load("//tools:defaults.bzl", "pkg_npm", "ts_library") | ||
|
||
licenses(["notice"]) # MIT | ||
|
||
ts_library( | ||
name = "create", | ||
package_name = "@angular/create", | ||
srcs = glob( | ||
["**/*.ts"], | ||
exclude = [ | ||
# NB: we need to exclude the nested node_modules that is laid out by yarn workspaces | ||
"node_modules/**", | ||
], | ||
), | ||
deps = [ | ||
"//packages/angular/cli:angular-cli", | ||
"@npm//@types/node", | ||
], | ||
) | ||
|
||
genrule( | ||
name = "license", | ||
srcs = ["//:LICENSE"], | ||
outs = ["LICENSE"], | ||
cmd = "cp $(execpath //:LICENSE) $@", | ||
) | ||
|
||
pkg_npm( | ||
name = "npm_package", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":README.md", | ||
":create", | ||
":license", | ||
], | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# `@angular/create` | ||
|
||
# Create an Angular CLI workspace | ||
|
||
Scaffold an Angular CLI workspace without needing to install the Angular CLI globally. All of the [ng new](https://angular.io/cli/new) options and features are supported. | ||
|
||
# Usage | ||
|
||
NPM | ||
|
||
``` | ||
npm init @angular@latest [project-name] -- [...options] | ||
``` | ||
|
||
Yarn | ||
|
||
``` | ||
yarn create @angular [project-name] [...options] | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@angular/create", | ||
"version": "0.0.0-PLACEHOLDER", | ||
"description": "Scaffold an Angular CLI workspace.", | ||
"keywords": [ | ||
"angular", | ||
"angular-cli", | ||
"Angular CLI", | ||
"code generation", | ||
"schematics" | ||
], | ||
"bin": { | ||
"create": "./src/index.js" | ||
}, | ||
"dependencies": { | ||
"@angular/cli": "0.0.0-PLACEHOLDER" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env node | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { spawnSync } from 'child_process'; | ||
import { join } from 'path'; | ||
|
||
const binPath = join(require.resolve('@angular/cli/package.json'), '../bin/ng.js'); | ||
|
||
// Invoke ng new with any parameters provided. | ||
const { error } = spawnSync(process.execPath, [binPath, 'new', ...process.argv.slice(2)], { | ||
stdio: 'inherit', | ||
}); | ||
|
||
if (error) { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
process.exitCode = 1; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { join, resolve } from 'path'; | ||
import { expectFileToExist, rimraf } from '../../utils/fs'; | ||
import { getActivePackageManager } from '../../utils/packages'; | ||
import { silentNpm, silentYarn } from '../../utils/process'; | ||
|
||
export default async function () { | ||
const currentDirectory = process.cwd(); | ||
const newDirectory = resolve('../'); | ||
|
||
const projectName = 'test-project-create'; | ||
|
||
try { | ||
process.chdir(newDirectory); | ||
const packageManager = getActivePackageManager(); | ||
|
||
switch (packageManager) { | ||
case 'npm': | ||
await silentNpm('init', '@angular', projectName, '--', '--skip-install', '--style=scss'); | ||
|
||
break; | ||
case 'yarn': | ||
await silentYarn('create', '@angular', projectName, '--skip-install', '--style=scss'); | ||
|
||
break; | ||
default: | ||
throw new Error(`This test is not configured to use ${packageManager}.`); | ||
} | ||
|
||
await expectFileToExist(join(projectName, 'angular.json')); | ||
// Verify styles was create with correct extension. | ||
await expectFileToExist(join(projectName, 'src/styles.scss')); | ||
} finally { | ||
await rimraf(projectName); | ||
// Change directory back | ||
process.chdir(currentDirectory); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ export async function prepareProjectForE2e(name: string) { | |
const argv: yargsParser.Arguments = getGlobalVariable('argv'); | ||
|
||
await git('config', 'user.email', '[email protected]'); | ||
await git('config', 'user.name', 'Angular CLI E2e'); | ||
await git('config', 'user.name', 'Angular CLI E2E'); | ||
await git('config', 'commit.gpgSign', 'false'); | ||
|
||
if (argv['ng-snapshots'] || argv['ng-tag']) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Is
@latest
necessary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for NPM this is needed as otherwise if this command was previously used, the cached binary will be used.