Skip to content

Commit 99f6454

Browse files
committed
chore: cleanup
1 parent 2297ae2 commit 99f6454

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ npm start
1313
- @nativescript/fingerprint-auth
1414
- @nativescript/geolocation
1515
- @nativescript/imagepicker
16+
- @nativescript/intl
1617
- @nativescript/iqkeyboardmanager
1718
- @nativescript/local-notifications
1819
- @nativescript/shared-notification-delegate

tools/schematics/sync-packages-with-demos/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ function addToDemoIndex(type: SupportedDemoType, demoAppRoot: string) {
8383
return (tree: Tree, context: SchematicContext) => {
8484
checkPackages(tree, context);
8585
if (type === 'angular') {
86-
resetAngularIndex(tree, getPackageNamesToUpdate());
87-
resetAngularRoutes(tree, getPackageNamesToUpdate());
86+
resetAngularIndex(tree, getPackageNamesToUpdate(), true);
87+
resetAngularRoutes(tree, getPackageNamesToUpdate(), true);
8888
return tree;
8989
}
9090

tools/schematics/utils/index.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,29 @@ export function getDemoIndexPathForType(type: SupportedDemoType): string {
182182
}
183183
}
184184

185-
export function resetAngularIndex(tree: Tree, packages?: Array<string>) {
185+
export function getPackagesForIndex(tree: Tree, packages?: Array<string>, addingNew?: boolean) {
186+
if (addingNew) {
187+
// just add to all packages
188+
const allPackages = <Array<string>>getAllPackages(tree);
189+
for (const p of packages) {
190+
if (!allPackages.includes(p)) {
191+
allPackages.push(p);
192+
}
193+
}
194+
packages = allPackages;
195+
} else {
196+
// isolate to packages or fallback to all
197+
packages = packages && packages.length ? packages : getAllPackages(tree);
198+
}
199+
return packages;
200+
}
201+
202+
export function resetAngularIndex(tree: Tree, packages?: Array<string>, addingNew?: boolean) {
186203
const angularIndexPath = `${getDemoAppRoot('angular')}/${getDemoIndexPathForType('angular')}`;
187204
let angularIndex = tree.get(angularIndexPath).content.toString();
188-
const demosIndex = angularIndex.indexOf('[');
189-
packages = packages && packages.length ? packages : getAllPackages(tree);
205+
const demosIndex = angularIndex.indexOf('[');
206+
packages = getPackagesForIndex(tree, packages, addingNew);
207+
190208
angularIndex =
191209
angularIndex.substring(0, demosIndex + 1) +
192210
packages
@@ -197,15 +215,15 @@ export function resetAngularIndex(tree: Tree, packages?: Array<string>) {
197215
tree.overwrite(angularIndexPath, angularIndex);
198216
}
199217

200-
export function resetAngularRoutes(tree: Tree, packages?: Array<string>) {
218+
export function resetAngularRoutes(tree: Tree, packages?: Array<string>, addingNew?: boolean) {
201219
const angularRouteModulePath = `${getDemoAppRoot('angular')}/src/app-routing.module.ts`;
202220
let angularRouteModule = tree.get(angularRouteModulePath).content.toString();
203221
const routeDefIndex = angularRouteModule.indexOf('const routes');
204222
const routeModuleStart = angularRouteModule.substring(0, routeDefIndex);
205223
const routeMoudleDefIndex = angularRouteModule.indexOf('@NgModule');
206224
const routeModuleEnd = angularRouteModule.substring(routeMoudleDefIndex, angularRouteModule.length);
207-
208-
packages = packages && packages.length ? packages : getAllPackages(tree);
225+
packages = getPackagesForIndex(tree, packages, addingNew);
226+
209227
const packageRoutes =
210228
packages
211229
.sort()

0 commit comments

Comments
 (0)