Skip to content

Commit 77f5cb1

Browse files
Merge pull request #3982 from NativeScript/vladimirov/drop-support-macos-sierra
feat: drop support for macOS Sierra and below
2 parents fc5dba3 + 8545629 commit 77f5cb1

File tree

14 files changed

+95
-35
lines changed

14 files changed

+95
-35
lines changed

lib/commands/debug.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export class DebugIOSCommand implements ICommand {
135135
private $platformService: IPlatformService,
136136
private $options: IOptions,
137137
private $injector: IInjector,
138+
private $sysInfo: ISysInfo,
138139
private $projectData: IProjectData,
139140
$iosDeviceOperations: IIOSDeviceOperations,
140141
$iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider) {
@@ -161,6 +162,12 @@ export class DebugIOSCommand implements ICommand {
161162
this.$errors.fail(`Timeout option specifies the seconds NativeScript CLI will wait to find the inspector socket port from device's logs. Must be a number.`);
162163
}
163164

165+
if (this.$options.inspector) {
166+
const macOSWarning = await this.$sysInfo.getMacOSWarningMessage();
167+
if (macOSWarning && macOSWarning.severity === SystemWarningsSeverity.high) {
168+
this.$errors.fail(`You cannot use NativeScript Inspector on this OS. To use it, please update your OS.`);
169+
}
170+
}
164171
const result = await this.debugPlatformCommand.canExecute(args);
165172
return result;
166173
}

lib/common/declarations.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,12 @@ interface IDeviceLiveSyncService extends IDeviceLiveSyncServiceBase {
11431143
afterInstallApplicationAction?(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<boolean>;
11441144
}
11451145

1146+
interface ISystemWarning {
1147+
message: string;
1148+
severity: SystemWarningsSeverity;
1149+
toString?: () => string;
1150+
}
1151+
11461152
interface ISysInfo {
11471153
getSysInfo(config?: NativeScriptDoctor.ISysInfoConfig): Promise<NativeScriptDoctor.ISysInfoData>;
11481154
/**
@@ -1163,15 +1169,15 @@ interface ISysInfo {
11631169

11641170
/**
11651171
* Gets all global warnings for the current environment, for example Node.js version compatibility, OS compatibility, etc.
1166-
* @return {Promise<string[]>} All warnings. Empty array is returned in case the system is setup correctly.
1172+
* @return {Promise<ISystemWarning[]>} All warnings. Empty array is returned in case the system is setup correctly.
11671173
*/
1168-
getSystemWarnings(): Promise<string[]>;
1174+
getSystemWarnings(): Promise<ISystemWarning[]>;
11691175

11701176
/**
11711177
* Gets warning message for current macOS version.
11721178
* @return {Promise<string>} Message in case the current macOS version is deprecated, null otherwise.
11731179
*/
1174-
getMacOSWarningMessage(): Promise<string>;
1180+
getMacOSWarningMessage(): Promise<ISystemWarning>;
11751181

11761182
/**
11771183
* Returns the value of engines.node key from CLI's package.json file.

lib/common/definitions/logger.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ interface ILogger {
1616
prepare(item: any): string;
1717
printInfoMessageOnSameLine(message: string): void;
1818
printMsgWithTimeout(message: string, timeout: number): Promise<void>;
19+
printOnStderr(formatStr?: any, ...args: any[]): void;
1920
}

lib/common/host-info.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,7 @@ export class HostInfo implements IHostInfo {
5757
try {
5858
const systemProfileOutput = await this.$childProcess.exec(systemProfileCommand);
5959

60-
// Output of command is similar to:
61-
/*
62-
Software:
63-
64-
System Software Overview:
65-
66-
System Version: macOS 10.13.3 (17D47)
67-
Kernel Version: Darwin 17.4.0
68-
Time since boot: 68 days 22:12
69-
*/
70-
const versionRegExp = /System Version:\s+?macOS\s+?(\d+\.\d+)\.\d+\s+/g;
60+
const versionRegExp = /System Version:\s+?macOS\s+?(\d+\.\d+)(\.\d+)?\s+/g;
7161
const regExpMatchers = versionRegExp.exec(systemProfileOutput);
7262
const macOSVersion = regExpMatchers && regExpMatchers[1];
7363
if (macOSVersion) {

lib/common/logger.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ export class Logger implements ILogger {
148148
this.write(formattedMessage);
149149
}
150150

151+
public printOnStderr(...args: string[]): void {
152+
if (process.stderr) {
153+
process.stderr.write(util.format.apply(null, args));
154+
}
155+
}
156+
151157
private getPasswordEncodedArguments(args: string[]): string[] {
152158
return _.map(args, argument => {
153159
if (typeof argument === 'string' && !!argument.match(/password/i)) {

lib/common/test/unit-tests/host-info.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@ describe("hostInfo", () => {
6565
assert.equal(calledCommand, "system_profiler SPSoftwareDataType -detailLevel mini");
6666
});
6767

68+
it("returns correct macOS version based on system_profile, when version has two numbers only", async () => {
69+
const testInjector = createTestInjector();
70+
const hostInfo = testInjector.resolve<IHostInfo>("hostInfo");
71+
const childProcess = testInjector.resolve<IChildProcess>("childProcess");
72+
let calledCommand = "";
73+
childProcess.exec = async (command: string, options?: any, execOptions?: IExecOptions): Promise<any> => {
74+
calledCommand = command;
75+
return `Software:
76+
77+
System Software Overview:
78+
79+
System Version: macOS 10.14 (18A391)
80+
Kernel Version: Darwin 18.0.0
81+
Time since boot: 1 day 5:52`;
82+
};
83+
84+
const macOSVersion = await hostInfo.getMacOSVersion();
85+
assert.deepEqual(macOSVersion, "10.14");
86+
assert.equal(calledCommand, "system_profiler SPSoftwareDataType -detailLevel mini");
87+
});
88+
6889
it("returns correct macOS version when system_profile call throws", async () => {
6990
const testInjector = createTestInjector();
7091
const hostInfo = testInjector.resolve<IHostInfo>("hostInfo");

lib/common/test/unit-tests/stubs.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export class CommonLoggerStub implements ILogger {
4141
printMarkdown(message: string): void {
4242
this.output += message;
4343
}
44+
45+
printOnStderr(...args: string[]): void {
46+
// nothing to do here
47+
}
4448
}
4549

4650
export class ErrorsStub implements IErrors {

lib/common/verify-node-version.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ export function verifyNodeVersion(): void {
4848
}
4949

5050
var nodeWarning = getNodeWarning();
51-
if (nodeWarning) {
52-
console.warn((os.EOL + nodeWarning + os.EOL).yellow.bold);
51+
if (nodeWarning && nodeWarning.message) {
52+
console.warn((`${os.EOL}${nodeWarning.message}${os.EOL}`).yellow.bold);
5353
}
5454
}
5555

56-
export function getNodeWarning(): string {
56+
export function getNodeWarning(): ISystemWarning {
5757
var verificationOpts = getNodeVersionOpts();
5858
var cliName = verificationOpts.cliName;
5959
var supportedVersionsRange = verificationOpts.supportedVersionsRange;
@@ -78,6 +78,9 @@ export function getNodeWarning(): string {
7878
}
7979
}
8080

81-
return warningMessage;
81+
return {
82+
message: warningMessage,
83+
severity: SystemWarningsSeverity.medium
84+
};
8285
}
8386
/* tslint:enable */

lib/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,10 @@ export class AssetConstants {
186186
export class MacOSVersions {
187187
public static Sierra = "10.12";
188188
public static HighSierra = "10.13";
189+
public static Mojave = "10.14";
189190
}
190191

191-
export const MacOSDeprecationStringFormat = "Support for macOS %s is deprecated and will be removed in one of the next releases of NativeScript. Please, upgrade to the latest macOS version.";
192+
export const MacOSDeprecationStringFormat = "NativeScript does not support macOS %s and some functionality may not work. Please, upgrade to the latest macOS version.";
192193
export const PROGRESS_PRIVACY_POLICY_URL = "https://www.progress.com/legal/privacy-policy";
193194
export class SubscribeForNewsletterMessages {
194195
public static AgreeToReceiveEmailMsg = "I agree".green.bold + " to receive email communications from Progress Software or its Partners (`https://www.progress.com/partners/partner-directory`)," +

lib/definitions/system-warnings.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare const enum SystemWarningsSeverity {
2+
medium = "medium",
3+
high = "high"
4+
}

0 commit comments

Comments
 (0)