Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
fix(config): only read ionic-angular package json for version info in…
Browse files Browse the repository at this point in the history
… apps, not in the Ionic repo itself
  • Loading branch information
danbucholtz committed Nov 6, 2017
1 parent 0e90965 commit 700ca04
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
13 changes: 9 additions & 4 deletions src/build/util.ts
Expand Up @@ -4,7 +4,7 @@ import { getTsConfigAsync, TsConfig } from '../transpile';
import * as Constants from '../util/constants';
import { BuildError } from '../util/errors';
import { GlobResult, globAll } from '../util/glob-util';
import { getStringPropertyValue, readFileAsync, readJsonAsync, semverStringToObject } from '../util/helpers';
import { getBooleanPropertyValue, getStringPropertyValue, readFileAsync, readJsonAsync, semverStringToObject } from '../util/helpers';
import { BuildContext, } from '../util/interfaces';

export function scanSrcTsFiles(context: BuildContext) {
Expand Down Expand Up @@ -77,13 +77,18 @@ export async function readVersionOfDependencies(context: BuildContext) {
// read the package.json version from ionic, angular/core, and typescript
const promises: Promise<any>[] = [];
promises.push(readPackageVersion(context.angularCoreDir));
promises.push(readPackageVersion(context.ionicAngularDir));
if (!getBooleanPropertyValue(Constants.ENV_SKIP_IONIC_ANGULAR_VERSION)) {
promises.push(readPackageVersion(context.ionicAngularDir));
}
promises.push(readPackageVersion(context.typescriptDir));

const versions = await Promise.all(promises);
context.angularVersion = semverStringToObject(versions[0]);
context.ionicAngularVersion = semverStringToObject(versions[1]);
context.typescriptVersion = semverStringToObject(versions[2]);
if (!getBooleanPropertyValue(Constants.ENV_SKIP_IONIC_ANGULAR_VERSION)) {
context.ionicAngularVersion = semverStringToObject(versions[1]);
}
// index could be 1 or 2 depending on if you read ionic-angular, its always the last one bro
context.typescriptVersion = semverStringToObject(versions[versions.length - 1]);
}

export async function readPackageVersion(packageDir: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/util/config.spec.ts
Expand Up @@ -165,7 +165,7 @@ describe('config', () => {
expect(fakeConfig[Constants.ENV_TOAST_COMPONENT_FACTORY_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'toast', 'toast-component.ngfactory.js'));

expect(fakeConfig[Constants.ENV_PARSE_DEEPLINKS]).toBeTruthy();
expect(fakeConfig[Constants.ENV_BUILD_TO_ES5]).toEqual('true');
expect(fakeConfig[Constants.ENV_SKIP_IONIC_ANGULAR_VERSION]).toEqual('false');
expect(context.bundler).toEqual('webpack');
});

Expand Down
8 changes: 3 additions & 5 deletions src/util/config.ts
Expand Up @@ -350,12 +350,10 @@ export function generateContext(context?: BuildContext): BuildContext {
setProcessEnvVar(Constants.ENV_PARSE_DEEPLINKS, parseDeepLinks);
Logger.debug(`parseDeepLinks set to ${parseDeepLinks}`);

// default stand-alone builds to default to es5
// if closure is being used, don't worry about this as it already automatically converts to ES5
const skipReadIonicAngular = getConfigValue(context, '--skipIonicAngularVersion', null, Constants.ENV_SKIP_IONIC_ANGULAR_VERSION, Constants.ENV_SKIP_IONIC_ANGULAR_VERSION.toLowerCase(), 'false');
setProcessEnvVar(Constants.ENV_SKIP_IONIC_ANGULAR_VERSION, skipReadIonicAngular);
Logger.debug(`skipReadIonicAngular set to ${skipReadIonicAngular}`);

const buildToEs5 = getConfigValue(context, '--buildToEs5', null, Constants.ENV_BUILD_TO_ES5, Constants.ENV_BUILD_TO_ES5.toLowerCase(), 'true');
setProcessEnvVar(Constants.ENV_BUILD_TO_ES5, buildToEs5);
Logger.debug(`buildToEs5 set to ${buildToEs5}`);

if (!isValidBundler(context.bundler)) {
context.bundler = bundlerStrategy(context);
Expand Down
2 changes: 1 addition & 1 deletion src/util/constants.ts
Expand Up @@ -83,7 +83,6 @@ export const ENV_CACHE_LOADER = 'IONIC_CACHE_LOADER';
export const ENV_AOT_WRITE_TO_DISK = 'IONIC_AOT_WRITE_TO_DISK';
export const ENV_BAIL_ON_LINT_ERROR = 'IONIC_BAIL_ON_LINT_ERROR';
export const ENV_TYPE_CHECK_ON_LINT = 'IONIC_TYPE_CHECK_ON_LINT';
export const ENV_BUILD_TO_ES5 = 'IONIC_BUILD_TO_ES5';
export const ENV_ENABLE_LINT = 'IONIC_ENABLE_LINT';
export const ENV_DISABLE_LOGGING = 'IONIC_DISABLE_LOGGING';
export const ENV_START_WATCH_TIMEOUT = 'IONIC_START_WATCH_TIMEOUT';
Expand All @@ -92,6 +91,7 @@ export const ENV_POLYFILL_FILE_NAME = 'IONIC_POLYFILL_FILE_NAME';
export const ENV_PRINT_WEBPACK_DEPENDENCY_TREE = 'IONIC_PRINT_WEBPACK_DEPENDENCY_TREE';
export const ENV_PARSE_DEEPLINKS = 'IONIC_PARSE_DEEPLINKS';
export const ENV_PURGE_UNUSED_FONTS = 'IONIC_PURGE_UNUSED_FONTS';
export const ENV_SKIP_IONIC_ANGULAR_VERSION = 'IONIC_SKIP_IONIC_ANGULAR_VERSION';


/* Providers */
Expand Down

0 comments on commit 700ca04

Please sign in to comment.