Skip to content

Commit 998940f

Browse files
Merge pull request #5165 from NativeScript/vladimirov/merge-rel-master
chore: merge release in master
2 parents 5a45604 + 605d8be commit 998940f

10 files changed

+591
-15
lines changed

.npmignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ scratch/
3131
docs/html/
3232
dev/
3333

34-
.travis/**/*
34+
.travis/**/*
35+
generate_changelog.js

CHANGELOG.md

+39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
NativeScript CLI Changelog
22
================
3+
6.2.2 (2019, November 22)
4+
==
5+
6+
### Fixed
7+
* [Fixed #5126](https://github.com/NativeScript/nativescript-cli/issues/5126): CLI does not generate all icons
8+
9+
6.2.1 (2019, November 18)
10+
==
11+
12+
### Fixed
13+
* [Fixed #5120](https://github.com/NativeScript/nativescript-cli/issues/5120): Android resource directories are not prepared correctly
14+
* [Fixed #5105](https://github.com/NativeScript/nativescript-cli/issues/5105): App restarts when changing platform specific scss
15+
16+
6.2.0 (2019, November 1)
17+
==
18+
19+
### New
20+
* [Implemented #5038](https://github.com/NativeScript/nativescript-cli/issues/5038): Deprecate support for markingMode:full
21+
* [Implemented #5049](https://github.com/NativeScript/nativescript-cli/issues/5049): Android App Bundle Improvements
22+
* [Implemented #5060](https://github.com/NativeScript/nativescript-cli/issues/5060): Kotlin usage tracking in android builds
23+
* [Implemented #5096](https://github.com/NativeScript/nativescript-cli/issues/5096): Reduce the npm requests when checking if the project should be migrated
24+
* [Implemented #5104](https://github.com/NativeScript/nativescript-cli/pull/5104): Allow tag and range versions in the preview app plugin versions validation
25+
* [Implemented #5107](https://github.com/NativeScript/nativescript-cli/issues/5107): Support V8 Snapshots on Windows
26+
27+
### Fixed
28+
* [Fixed #3785](https://github.com/NativeScript/nativescript-cli/issues/3785): NativeScript CLI doesn't pause on webpack compilation errors
29+
* [Fixed #4681](https://github.com/NativeScript/nativescript-cli/issues/4681): `tns update ios` is not working
30+
* [Fixed #4963](https://github.com/NativeScript/nativescript-cli/issues/4963): Difference in hookArgs.prepareData.platform on prepare and run command
31+
* [Fixed #4995](https://github.com/NativeScript/nativescript-cli/issues/4995): Building plugin and running demo app fails if plugins has a surrounding gradle build
32+
* [Fixed #5005](https://github.com/NativeScript/nativescript-cli/issues/5005): Apple Watch extension with space in the name of `.entitlements` file is not working
33+
* [Fixed #5020](https://github.com/NativeScript/nativescript-cli/issues/5020): Stuck at "Restarting application on device" on Windows 10, iPad mini 2, compiled with NativeScript Sidekick cloud service.
34+
* [Fixed #5030](https://github.com/NativeScript/nativescript-cli/issues/5030): The `tns devices` command lists appletv as iOS platform
35+
* [Fixed #5034](https://github.com/NativeScript/nativescript-cli/issues/5034): Broken build when passing --i-cloud-container-environment
36+
* [Fixed #5056](https://github.com/NativeScript/nativescript-cli/issues/5056): Unable to process native iOS files and frameworks from scoped packages
37+
* [Fixed #5061](https://github.com/NativeScript/nativescript-cli/issues/5061): Unable to resolve cocoapods version conflicts
38+
* [Fixed #5063](https://github.com/NativeScript/nativescript-cli/issues/5063): Splash Screen asset generation fails for iOS
39+
* [Fixed #5070](https://github.com/NativeScript/nativescript-cli/issues/5070): The `tns test` command cannot work if the source code is not in `src` or `app` folder
40+
* [Fixed #5077](https://github.com/NativeScript/nativescript-cli/pull/5077): Pass allowProvisioningUpdates to xcodebuild only when building for device
41+
* [Fixed #5094](https://github.com/NativeScript/nativescript-cli/issues/5094): Add Theme v2 name to non-extenal modules when starting webpack
342

443
6.1.2 (2019, September 18)
544
==

generate_changelog.js

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
"use strict";
2+
3+
const _ = require("lodash");
4+
const request = require("request");
5+
const fs = require("fs");
6+
const path = require("path");
7+
require("colors");
8+
9+
const argv = process.argv;
10+
if (argv.length < 3 || argv.length > 4) {
11+
console.error(`Incorrect usage. You need to pass the milestone and optionally the Authorization token.\n`.red +
12+
`### Example:
13+
node generate_changelog.js 6.2.2 2d2156c261bb1494f7a6e22f11fa446c7ca0e6b7\n`.yellow);
14+
process.exit(127);
15+
}
16+
17+
const selectedMilestone = process.argv[2];
18+
const token = process.argv[3] || process.env.NS_CLI_CHANGELOG_AUTHORIZATION;
19+
if (!token) {
20+
console.error(`Unable to find Authorization token.\n`.red +
21+
`You must either set NS_CLI_CHANGELOG_AUTHORIZATION environment variable or pass the token as an argument to the script:\n`.yellow +
22+
`node generate_changelog.js 6.2.2 2d2156c261bb1494f7a6e22f11fa446c7ca0e6b7\n`.green);
23+
process.exit(127);
24+
}
25+
26+
const sendRequest = (query) => {
27+
return new Promise((resolve, reject) => {
28+
request.post("https://api.github.com/graphql", {
29+
headers: {
30+
"Accept": "application/json",
31+
"Authorization": `Bearer ${token}`,
32+
"User-Agent": "NativeScript CLI Changelog Generator"
33+
},
34+
body: JSON.stringify(query),
35+
followAllRedirects: true
36+
}, (err, response, body) => {
37+
if (err) {
38+
reject(err);
39+
return;
40+
}
41+
resolve(JSON.parse(body));
42+
});
43+
});
44+
};
45+
46+
const getMilestonesInfoQuery = {
47+
query: `{
48+
repository(owner:"NativeScript", name:"nativescript-cli") {
49+
milestones(first: 100, states: OPEN) {
50+
nodes {
51+
number
52+
id
53+
title
54+
url
55+
}
56+
}
57+
}
58+
}`
59+
};
60+
61+
sendRequest(getMilestonesInfoQuery)
62+
.then(result => {
63+
const milestones = result && result.data && result.data.repository && result.data.repository.milestones && result.data.repository.milestones.nodes || [];
64+
const matchingMilestone = _.find(milestones, m => m.title === selectedMilestone);
65+
if (!matchingMilestone) {
66+
throw new Error(`Unable to find milestone ${selectedMilestone} in the milestones. Current milestones info is: ${JSON.stringify(milestones, null, 2)}`);
67+
}
68+
return matchingMilestone.number;
69+
})
70+
.then((milestone) => {
71+
const getItemsForMilestoneQuery = {
72+
query: `{
73+
repository(owner:"NativeScript", name:"nativescript-cli") {
74+
milestone(number: ${milestone}) {
75+
number
76+
id
77+
issuePrioritiesDebug
78+
url
79+
issues(first: 100) {
80+
nodes {
81+
title
82+
url
83+
number
84+
labels(first:100) {
85+
edges {
86+
node {
87+
name
88+
}
89+
}
90+
}
91+
projectCards(first: 100) {
92+
nodes {
93+
column {
94+
name
95+
}
96+
project {
97+
name
98+
number
99+
}
100+
state
101+
}
102+
}
103+
}
104+
}
105+
}
106+
}
107+
}`
108+
};
109+
return sendRequest(getItemsForMilestoneQuery);
110+
})
111+
.then((milestoneQueryResult) => {
112+
const issues = (milestoneQueryResult && milestoneQueryResult.data && milestoneQueryResult.data.repository &&
113+
milestoneQueryResult.data.repository.milestone && milestoneQueryResult.data.repository.milestone.issues &&
114+
milestoneQueryResult.data.repository.milestone.issues.nodes) || [];
115+
const finalIssuesForChangelog = [];
116+
issues.forEach((issue) => {
117+
const labels = ((issue.labels && issue.labels.edges) || []).map((lblObj) => lblObj && lblObj.node && lblObj.node.name);
118+
const isFeature = labels.indexOf("feature") !== -1;
119+
const isBug = labels.indexOf("bug") !== -1;
120+
const shouldBeSkipped = labels.indexOf("no-changelog") !== -1;
121+
if (isFeature && isBug) {
122+
console.error(`The item '${issue.title}' has both bug and feature label. Clear one of them and try again.`.red);
123+
process.exit(1);
124+
} else if (shouldBeSkipped) {
125+
console.log(`Item ${issue && issue.url}(${issue && issue.title}) will not be included in changelog as it has no-changelog label`.yellow);
126+
} else {
127+
// check if we have resolved it:
128+
const columns = (issue && issue.projectCards && issue.projectCards.nodes || []).map(c => c && c.column && c.column.name);
129+
// There shouldn't be more than one columns.
130+
const column = _.first(columns);
131+
if (columns && column === "Ready for Test" || column === "In Testing" || column === "Done") {
132+
finalIssuesForChangelog.push({
133+
type: isFeature ? "feature" : "bug",
134+
number: issue && issue.number,
135+
title: issue && issue.title,
136+
url: issue && issue.url
137+
});
138+
} else {
139+
console.log(`Item ${issue && issue.url}(${issue && issue.title}) will not be included in changelog as its status is ${columns}`.yellow);
140+
}
141+
}
142+
});
143+
144+
return finalIssuesForChangelog;
145+
})
146+
.then(data => {
147+
const features = [];
148+
const bugs = [];
149+
150+
_.sortBy(data, (d) => d.number)
151+
.forEach(d => {
152+
if (d.type === "feature") {
153+
features.push(`* [Implemented #${d.number}](${d.url}): ${d.title}`);
154+
} else {
155+
bugs.push(`* [Fixed #${d.number}](${d.url}): ${d.title}`);
156+
}
157+
});
158+
159+
const pathToChangelog = path.join(__dirname, "CHANGELOG.md");
160+
let changelogContent = fs.readFileSync(pathToChangelog).toString();
161+
162+
if (features.length === 0 && bugs.length === 0) {
163+
console.error(`Unable to find anything ready for milestone ${selectedMilestone}`.red);
164+
process.exit(2);
165+
}
166+
167+
const monthNames = ["January", "February", "March", "April", "May", "June",
168+
"July", "August", "September", "October", "November", "December"
169+
];
170+
const currentDate = new Date();
171+
172+
let newChangelogContent = `\n${selectedMilestone} (${currentDate.getFullYear()}, ${monthNames[currentDate.getMonth()]} ${currentDate.getDate()})
173+
===
174+
`;
175+
if (features.length > 0) {
176+
newChangelogContent += `
177+
### New
178+
179+
${features.join("\n")}
180+
`;
181+
}
182+
if (bugs.length) {
183+
newChangelogContent += `
184+
### Fixed
185+
186+
${bugs.join("\n")}
187+
`;
188+
}
189+
190+
changelogContent = changelogContent.replace(/(NativeScript CLI Changelog\r?\n=+\r?\n)([\s\S]*)/m, `$1${newChangelogContent}\n$2`);
191+
fs.writeFileSync(pathToChangelog, changelogContent);
192+
console.log(`Successfully added Changelog for ${selectedMilestone}`.green);
193+
console.log("Commit the local changes and send a PR.".magenta);
194+
})
195+
.catch(error => console.error(error));

lib/controllers/migrate-controller.ts

+3
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,14 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`;
163163
const cachedResult = await this.getCachedShouldMigrate(projectDir, platform);
164164
if (cachedResult !== false) {
165165
remainingPlatforms.push(platform);
166+
} else {
167+
this.$logger.trace(`Got cached result for shouldMigrate for platform: ${platform}`);
166168
}
167169
}
168170

169171
if (remainingPlatforms.length > 0) {
170172
shouldMigrate = await this._shouldMigrate({ projectDir, platforms: remainingPlatforms, allowInvalidVersions });
173+
this.$logger.trace(`Executed shouldMigrate for platforms: ${remainingPlatforms}. Result is: ${shouldMigrate}`);
171174

172175
if (!shouldMigrate) {
173176
for (const remainingPlatform of remainingPlatforms) {

lib/services/android-project-service.ts

+37-8
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,23 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
142142

143143
this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, "*", "-R");
144144

145+
// TODO: Check if we actually need this and if it should be targetSdk or compileSdk
145146
this.cleanResValues(targetSdkVersion, projectData);
146147
}
147148

149+
private getResDestinationDir(projectData: IProjectData): string {
150+
const appResourcesDirStructureHasMigrated = this.$androidResourcesMigrationService.hasMigrated(projectData.getAppResourcesDirectoryPath());
151+
152+
if (appResourcesDirStructureHasMigrated) {
153+
const appResourcesDestinationPath = this.getUpdatedAppResourcesDestinationDirPath(projectData);
154+
return path.join(appResourcesDestinationPath, constants.MAIN_DIR, constants.RESOURCES_DIR);
155+
} else {
156+
return this.getLegacyAppResourcesDestinationDirPath(projectData);
157+
}
158+
}
159+
148160
private cleanResValues(targetSdkVersion: number, projectData: IProjectData): void {
149-
const resDestinationDir = this.getAppResourcesDestinationDirectoryPath(projectData);
161+
const resDestinationDir = this.getResDestinationDir(projectData);
150162
const directoriesInResFolder = this.$fs.readDirectory(resDestinationDir);
151163
const directoriesToClean = directoriesInResFolder
152164
.map(dir => {
@@ -283,7 +295,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
283295
const projectAppResourcesPath = projectData.getAppResourcesDirectoryPath(projectData.projectDir);
284296
const platformsAppResourcesPath = this.getAppResourcesDestinationDirectoryPath(projectData);
285297

286-
this.cleanUpPreparedResources(projectAppResourcesPath, projectData);
298+
this.cleanUpPreparedResources(projectData);
287299

288300
this.$fs.ensureDirectoryExists(platformsAppResourcesPath);
289301

@@ -296,6 +308,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
296308
// App_Resources/Android/libs is reserved to user's aars and jars, but they should not be copied as resources
297309
this.$fs.deleteDirectory(path.join(platformsAppResourcesPath, "libs"));
298310
}
311+
312+
const androidToolsInfo = this.$androidToolsInfo.getToolsInfo({ projectDir: projectData.projectDir });
313+
const compileSdkVersion = androidToolsInfo && androidToolsInfo.compileSdkVersion;
314+
this.cleanResValues(compileSdkVersion, projectData);
299315
}
300316

301317
public async preparePluginNativeCode(pluginData: IPluginData, projectData: IProjectData): Promise<void> {
@@ -431,18 +447,31 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
431447
return path.join(this.getPlatformData(projectData).projectRoot, ...resourcePath);
432448
}
433449

434-
private cleanUpPreparedResources(appResourcesDirectoryPath: string, projectData: IProjectData): void {
435-
let resourcesDirPath = path.join(appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName);
450+
/**
451+
* The purpose of this method is to delete the previously prepared user resources.
452+
* The content of the `<platforms>/android/.../res` directory is based on user's resources and gradle project template from android-runtime.
453+
* During preparation of the `<path to user's App_Resources>/Android` we want to clean all the users files from previous preparation,
454+
* but keep the ones that were introduced during `platform add` of the android-runtime.
455+
* Currently the Gradle project template contains resources only in values and values-v21 directories.
456+
* So the current logic of the method is cleaning al resources from `<platforms>/android/.../res` that are not in `values.*` directories
457+
* and that exist in the `<path to user's App_Resources>/Android/.../res` directory
458+
* This means that if user has a resource file in values-v29 for example, builds the project and then deletes this resource,
459+
* it will be kept in platforms directory. Reference issue: `https://github.com/NativeScript/nativescript-cli/issues/5083`
460+
* Same is valid for files in `drawable-<resolution>` directories - in case in user's resources there's drawable-hdpi directory,
461+
* which is deleted after the first build of app, it will remain in platforms directory.
462+
*/
463+
private cleanUpPreparedResources(projectData: IProjectData): void {
464+
let resourcesDirPath = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName);
436465
if (this.$androidResourcesMigrationService.hasMigrated(projectData.appResourcesDirectoryPath)) {
437-
resourcesDirPath = path.join(resourcesDirPath, constants.MAIN_DIR, constants.RESOURCES_DIR);
466+
resourcesDirPath = path.join(resourcesDirPath, constants.SRC_DIR, constants.MAIN_DIR, constants.RESOURCES_DIR);
438467
}
439468

440469
const valuesDirRegExp = /^values/;
441470
if (this.$fs.exists(resourcesDirPath)) {
442471
const resourcesDirs = this.$fs.readDirectory(resourcesDirPath).filter(resDir => !resDir.match(valuesDirRegExp));
443-
const appResourcesDestinationDirectoryPath = this.getAppResourcesDestinationDirectoryPath(projectData);
444-
_.each(resourcesDirs, resourceDir => {
445-
this.$fs.deleteDirectory(path.join(appResourcesDestinationDirectoryPath, resourceDir));
472+
const resDestinationDir = this.getResDestinationDir(projectData);
473+
_.each(resourcesDirs, currentResource => {
474+
this.$fs.deleteDirectory(path.join(resDestinationDir, currentResource));
446475
});
447476
}
448477
}

lib/services/project-data-service.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,15 @@ export class ProjectDataService implements IProjectDataService {
282282
}
283283
});
284284

285-
if (!foundMatchingDefinition && image.filename) {
286-
this.$logger.warn(`Didn't find a matching image definition for file ${path.join(path.basename(dirPath), image.filename)}. This file will be skipped from reources generation.`);
285+
if (!foundMatchingDefinition) {
286+
if (image.height && image.width) {
287+
this.$logger.trace("Missing data for image", image, " in CLI's resource file, but we will try to generate images based on the size from Contents.json");
288+
finalContent.images.push(image);
289+
} else if (image.filename) {
290+
this.$logger.warn(`Didn't find a matching image definition for file ${path.join(path.basename(dirPath), image.filename)}. This file will be skipped from resources generation.`);
291+
} else {
292+
this.$logger.trace(`Unable to detect data for image generation of image`, image);
293+
}
287294
}
288295
});
289296

lib/services/webpack/webpack-compiler-service.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
4242
if (message.emittedFiles) {
4343
if (isFirstWebpackWatchCompilation) {
4444
isFirstWebpackWatchCompilation = false;
45-
this.expectedHashes[platformData.platformNameLowerCase] = message.hash;
45+
this.expectedHashes[platformData.platformNameLowerCase] = prepareData.hmr ? message.hash : "";
46+
return;
47+
}
48+
49+
// the hash of the compilation is the same as the previous one
50+
if (this.expectedHashes[platformData.platformNameLowerCase] === message.hash) {
4651
return;
4752
}
4853

0 commit comments

Comments
 (0)