Skip to content

Commit

Permalink
docs: fixed animation broken stackblitz example
Browse files Browse the repository at this point in the history
This commit fixes the broken stackblitz example of animation.

Closes #41838.
  • Loading branch information
iRealNirmal committed May 9, 2021
1 parent cd252b9 commit d0fcfd9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
3 changes: 2 additions & 1 deletion aio/content/examples/i18n/stackblitz.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"**/*.xlf"
],
"file": "src/app/app.component.ts",
"tags": ["Angular", "i18n", "internationalization"]
"tags": ["Angular", "i18n", "internationalization"],
"devDependencies": ["@angular/compiler-cli", "typescript"]
}
3 changes: 2 additions & 1 deletion aio/content/examples/testing/stackblitz.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@

"!src/**/*.spec.ts"
],
"tags": ["testing"]
"tags": ["testing"],
"devDependencies": ["jasmine-core", "jasmine-marbles"]
}
3 changes: 1 addition & 2 deletions aio/tools/examples/shared/boilerplate/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.1.5"
"tslint": "~6.1.0"
}
}
29 changes: 25 additions & 4 deletions aio/tools/stackblitz-builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,40 @@ class StackblitzBuilder {
}
}

_addDependencies(config, postData) {
_addDependencies(config, postData, stackBlitzJson) {
// Extract npm package dependencies
const exampleType = this._getExampleType(config.basePath);
const packageJson = this._getBoilerplatePackageJson(exampleType) || this._getBoilerplatePackageJson('cli');
const testStackblitzestPath = path.join(this.basePath, '/testing/stackblitz.json');
const stackblitzJsonDevDependencies = this._getDevDependencies(stackBlitzJson);
const stackblitzJsonTestDependencies = this._getDevDependencies(testStackblitzestPath);
const exampleDependencies = packageJson.dependencies;

// Add unit test packages from devDependencies for unit test examples

const devDependencies = packageJson.devDependencies;
['jasmine-core', 'jasmine-marbles'].forEach(dep => exampleDependencies[dep] = devDependencies[dep]);
// Add unit test packages from devDependencies for unit test examples
stackblitzJsonTestDependencies.forEach(dep => exampleDependencies[dep] = devDependencies[dep]);
// Add unit test packages from devDependencies for unit example if exists
stackblitzJsonDevDependencies.forEach(dep => exampleDependencies[dep] = devDependencies[dep]);

postData.dependencies = JSON.stringify(exampleDependencies);
}

/**
* Get devDependecies from the file path passed as parameter
*
* @param path file path to get from and reuse this method
* @returns devDependencies of file else blank array in case it doesn't exists
*/
_getDevDependencies(path) {
let file;
if (path) {
const filePath = `${path}`;
file = fs.existsSync(filePath) ? require(filePath) : null;
}
return file?.devDependencies|| [];
}

_getExampleType(exampleDir) {
const configPath = `${exampleDir}/example-config.json`;
const configSrc = fs.existsSync(configPath) && fs.readFileSync(configPath, 'utf-8').trim();
Expand Down Expand Up @@ -100,7 +121,7 @@ class StackblitzBuilder {
try {
const config = this._initConfigAndCollectFileNames(configFileName);
const postData = this._createPostData(config, configFileName);
this._addDependencies(config, postData);
this._addDependencies(config, postData, configFileName);
const html = this._createStackblitzHtml(config, postData);
fs.writeFileSync(outputFileName, html, 'utf-8');
if (altFileName) {
Expand Down

0 comments on commit d0fcfd9

Please sign in to comment.