-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add local package.json to schematics collection (#298)
Check local package.json for the schematics attribute. when available add the path to the collection. Fixed the create of the e2e fixture.
- Loading branch information
Showing
4 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
apps/angular-console-e2e/src/integration/local-collection.spec.ts
This file contains 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,71 @@ | ||
import { | ||
checkDisplayedCommand, | ||
clickOnTask, | ||
goBack, | ||
goToGenerate, | ||
openProject, | ||
projectPath, | ||
taskListHeaders, | ||
tasks, | ||
texts, | ||
uniqName, | ||
whitelistGraphql | ||
} from './utils'; | ||
import { clearRecentTask } from './tasks.utils'; | ||
|
||
describe('Project with local collection', () => { | ||
beforeEach(() => { | ||
whitelistGraphql(); | ||
cy.visit('/workspaces'); | ||
openProject(projectPath('proj-local-collection')); | ||
goToGenerate(); | ||
cy.get('div.title').contains('Generate Code'); | ||
}); | ||
|
||
it('shows the local schematics', () => { | ||
taskListHeaders($p => { | ||
expect($p.length).to.equal(3); | ||
expect(texts($p)[0]).to.equal('.proj-local-collection'); | ||
}); | ||
|
||
tasks($p => { | ||
const t = texts($p); | ||
expect(t.indexOf('my-full-schematic') > -1).to.equal(true); | ||
}); | ||
}); | ||
|
||
it('runs a local schematic', () => { | ||
clickOnTask('.proj-local-collection', 'my-full-schematic'); | ||
cy.get('div.context-title').contains( | ||
'A schematic using a source and a schema to validate options' | ||
); | ||
|
||
const name = uniqName('example'); | ||
cy.get('input[name="name"]').type(name); | ||
|
||
cy.wait(100); | ||
|
||
cy.get('button') | ||
.contains('Generate') | ||
.click(); | ||
|
||
cy.wait(100); | ||
|
||
checkDisplayedCommand(`$ ng generate .:my-full-schematic --name=${name}`); | ||
cy.readFile('./../../tmp/proj-local-collection/hola'); | ||
cy.readFile('./../../tmp/proj-local-collection/allo'); | ||
|
||
goBack(); | ||
|
||
cy.get('div.title').contains('Generate Code'); | ||
taskListHeaders($p => { | ||
expect(texts($p)[0]).to.equal('.proj-local-collection'); | ||
}); | ||
}); | ||
|
||
after(() => { | ||
cy.visit('/workspaces'); | ||
openProject(projectPath('proj-local-collection')); | ||
clearRecentTask(); | ||
}); | ||
}); |
This file contains 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 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 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 |
---|---|---|
|
@@ -14,10 +14,14 @@ shell.rm('-rf', path.join(tmp, 'proj-extensions')); | |
shell.mkdir(path.join(tmp, 'proj-extensions')); | ||
shell.rm('-rf', path.join(tmp, 'proj-no-node-modules')); | ||
shell.mkdir(path.join(tmp, 'proj-no-node-modules')); | ||
shell.rm('-rf', path.join(tmp, 'proj-local-collection')); | ||
shell.mkdir(path.join(tmp, 'proj-local-collection')); | ||
|
||
shell.rm('-rf', path.join(tmp, 'ng')); | ||
shell.mkdir(path.join(tmp, 'ng')); | ||
cp.execSync('yarn add @angular/[email protected]', {cwd: path.join(tmp, 'ng')}); | ||
cp.execSync('yarn add @angular-devkit/schematics-cli @schematics/schematics', {cwd: path.join(tmp, 'ng')}); | ||
cp.execSync('yarn add json', {cwd: path.join(tmp, 'ng')}); | ||
|
||
cp.execSync('ng config -g cli.packageManager yarn'); | ||
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/ng new proj --collection=@schematics/angular --directory=proj --skip-git --no-interactive`, { cwd: tmp, stdio: [0, 1, 2] }); | ||
|
@@ -28,3 +32,12 @@ shell.mv(path.join(tmp, 'proj-extensions'), './tmp/proj-extensions'); | |
|
||
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/ng new proj-no-node-modules --collection=@schematics/angular --directory=proj-no-node-modules --skip-install --skip-git --no-interactive`, { cwd: tmp, stdio: [0, 1, 2] }); | ||
shell.mv(path.join(tmp, 'proj-no-node-modules'), './tmp/proj-no-node-modules'); | ||
|
||
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/ng new proj-local-collection --collection=@schematics/angular --directory=proj-local-collection --skip-git --no-interactive`, { cwd: tmp, stdio: [0, 1, 2] }); | ||
shell.mv(path.join(tmp, 'proj-local-collection'), './tmp/proj-local-collection'); | ||
shell.cd('./tmp/proj-local-collection'); | ||
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/schematics schematic --name=schematics .`); | ||
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/json -I -f package.json -e 'this.schematics="./schematics/src/collection.json"'`); | ||
cp.execSync('ng config cli.defaultCollection schematics') | ||
shell.cd('schematics'); | ||
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/tsc`); |