Skip to content

Commit c3af7fb

Browse files
Merge pull request #2872 from NativeScript/vladimirov/merge-rel-master
Merge release in master
2 parents b615149 + 66a47ad commit c3af7fb

File tree

7 files changed

+62
-24
lines changed

7 files changed

+62
-24
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
NativeScript CLI Changelog
22
================
33

4+
3.0.3 (2017, June 1)
5+
==
6+
7+
### Fixed
8+
9+
* [Fix #2855](https://github.com/NativeScript/nativescript-cli/issues/2855): iOS inspector not installed with npm 5
10+
11+
3.0.2 (2017, May 30)
12+
==
13+
14+
### Fixed
15+
16+
* Removed restart of the App if HTML/CSS file was modified. The issue is fixed in the Modules **3.0.1** and we can again just refresh the app on change.
17+
* [Fix #2852](https://github.com/NativeScript/nativescript-cli/pull/2852): Fix prepare for android when building with webpack
18+
419
3.0.1 (2017, May 11)
520
==
621

722
### Fixed
823

9-
* [Fix #2780](https://github.com/NativeScript/nativescript-cli/issues/2780): CLI tool doesn't restart app if HTML/CSS file was modified
1024
* [Fix #2732](https://github.com/NativeScript/nativescript-cli/issues/2732): Livesync crashes app every OTHER time on iOS with 3.0.0-rc.2
1125
* [Fix #2764](https://github.com/NativeScript/nativescript-cli/issues/2764): Error when executing "tns run ios" with 3.0 on a project that is located in a directory path with "spaces"
1226

lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ export const TYPESCRIPT_NAME = "typescript";
7272
export const BUILD_OUTPUT_EVENT_NAME = "buildOutput";
7373
export const CONNECTION_ERROR_EVENT_NAME = "connectionError";
7474
export const VERSION_STRING = "version";
75+
export const INSPECTOR_CACHE_DIRNAME = "ios-inspector";

lib/npm-installation-manager.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,38 @@ export class NpmInstallationManager implements INpmInstallationManager {
4747
}
4848

4949
public async getInspectorFromCache(inspectorNpmPackageName: string, projectDir: string): Promise<string> {
50-
let inspectorPath = path.join(projectDir, "node_modules", inspectorNpmPackageName);
50+
let inspectorPath = path.join(projectDir, constants.NODE_MODULES_FOLDER_NAME, inspectorNpmPackageName);
5151

5252
// local installation takes precedence over cache
5353
if (!this.inspectorAlreadyInstalled(inspectorPath)) {
54-
let cachepath = (await this.$childProcess.exec("npm get cache")).trim();
55-
let version = await this.getLatestCompatibleVersion(inspectorNpmPackageName);
56-
let pathToPackageInCache = path.join(cachepath, inspectorNpmPackageName, version);
57-
let pathToUnzippedInspector = path.join(pathToPackageInCache, "package");
54+
const cachePath = path.join(this.$options.profileDir, constants.INSPECTOR_CACHE_DIRNAME);
55+
this.prepareCacheDir(cachePath);
56+
const pathToPackageInCache = path.join(cachePath, constants.NODE_MODULES_FOLDER_NAME, inspectorNpmPackageName);
5857

5958
if (!this.$fs.exists(pathToPackageInCache)) {
60-
await this.$childProcess.exec(`npm cache add ${inspectorNpmPackageName}@${version}`);
61-
let inspectorTgzPathInCache = path.join(pathToPackageInCache, "package.tgz");
62-
await this.$childProcess.exec(`tar -xf ${inspectorTgzPathInCache} -C ${pathToPackageInCache}`);
63-
await this.$childProcess.exec(`npm install --prefix ${pathToUnzippedInspector}`);
59+
const version = await this.getLatestCompatibleVersion(inspectorNpmPackageName);
60+
await this.$childProcess.exec(`npm install ${inspectorNpmPackageName}@${version} --prefix ${cachePath}`);
6461
}
62+
6563
this.$logger.out("Using inspector from cache.");
66-
return pathToUnzippedInspector;
64+
return pathToPackageInCache;
6765
}
66+
6867
return inspectorPath;
6968
}
7069

70+
private prepareCacheDir(cacheDirName: string): void {
71+
this.$fs.ensureDirectoryExists(cacheDirName);
72+
73+
const cacheDirPackageJsonLocation = path.join(cacheDirName, constants.PACKAGE_JSON_FILE_NAME);
74+
if (!this.$fs.exists(cacheDirPackageJsonLocation)) {
75+
this.$fs.writeJson(cacheDirPackageJsonLocation, {
76+
name: constants.INSPECTOR_CACHE_DIRNAME,
77+
version: "0.1.0"
78+
});
79+
}
80+
}
81+
7182
private inspectorAlreadyInstalled(pathToInspector: string): Boolean {
7283
if (this.$fs.exists(pathToInspector)) {
7384
return true;

lib/services/platform-service.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
233233
this.$logger.trace("Changes info in prepare platform:", changesInfo);
234234

235235
if (changesInfo.hasChanges) {
236-
// android build artifacts need to be cleaned up when switching from release to debug builds
237-
if (platform.toLowerCase() === "android") {
238-
let previousPrepareInfo = this.$projectChangesService.getPrepareInfo(platform, projectData);
239-
// clean up prepared plugins when not building for release
240-
if (previousPrepareInfo && previousPrepareInfo.release !== appFilesUpdaterOptions.release) {
241-
await platformData.platformProjectService.cleanProject(platformData.projectRoot, projectData);
242-
}
243-
}
244-
236+
await this.cleanProject(platform, appFilesUpdaterOptions, platformData, projectData);
245237
await this.preparePlatformCore(platform, appFilesUpdaterOptions, projectData, config, changesInfo, filesToSync);
246238
this.$projectChangesService.savePrepareInfo(platform, projectData);
247239
} else {
@@ -269,6 +261,25 @@ export class PlatformService extends EventEmitter implements IPlatformService {
269261
}
270262
}
271263

264+
private async cleanProject(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformData: IPlatformData, projectData: IProjectData): Promise<void> {
265+
// android build artifacts need to be cleaned up
266+
// when switching between debug, release and webpack builds
267+
if (platform.toLowerCase() !== "android") {
268+
return;
269+
}
270+
271+
const previousPrepareInfo = this.$projectChangesService.getPrepareInfo(platform, projectData);
272+
if (!previousPrepareInfo) {
273+
return;
274+
}
275+
276+
const { release: previousWasRelease, bundle: previousWasBundle } = previousPrepareInfo;
277+
const { release: currentIsRelease, bundle: currentIsBundle } = appFilesUpdaterOptions;
278+
if ((previousWasRelease !== currentIsRelease) || (previousWasBundle !== currentIsBundle)) {
279+
await platformData.platformProjectService.cleanProject(platformData.projectRoot, projectData);
280+
}
281+
}
282+
272283
/* Hooks are expected to use "filesToSync" parameter, as to give plugin authors additional information about the sync process.*/
273284
@helpers.hook('prepare')
274285
private async preparePlatformCore(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, projectData: IProjectData, platformSpecificData: IPlatformSpecificData, changesInfo?: IProjectChangesInfo, filesToSync?: Array<String>): Promise<void> {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nativescript",
33
"preferGlobal": true,
4-
"version": "3.0.1",
4+
"version": "3.0.3",
55
"author": "Telerik <support@telerik.com>",
66
"description": "Command-line interface for building NativeScript projects",
77
"bin": {

test/npm-support.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ async function setupProject(dependencies?: any): Promise<any> {
162162
interpolateConfigurationFile: (): void => undefined,
163163
isPlatformPrepared: (projectRoot: string) => false,
164164
validatePlugins: (projectData: IProjectData) => Promise.resolve(),
165-
checkForChanges: () => { /* */ }
165+
checkForChanges: () => { /* */ },
166+
cleanProject: () => Promise.resolve()
166167
}
167168
};
168169
};
@@ -319,7 +320,7 @@ describe("Flatten npm modules tests", () => {
319320
let gulpJshint = path.join(tnsModulesFolderPath, "gulp-jshint");
320321
assert.isFalse(fs.exists(gulpJshint));
321322

322-
// Get all gulp dependencies
323+
// Get all gulp dependencies
323324
let gulpJsonContent = fs.readJson(path.join(projectFolder, nodeModulesFolderName, "gulp", packageJsonName));
324325
_.each(_.keys(gulpJsonContent.dependencies), dependency => {
325326
assert.isFalse(fs.exists(path.join(tnsModulesFolderPath, dependency)));

0 commit comments

Comments
 (0)