How to use nativescript - 9 common examples

To help you get started, we’ve selected a few nativescript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NativeScript / nativescript-cloud / test / mobile / mobile-core / cloud-emulator-device-discovery.ts View on Github external
function createTestInjector(devices?: IAttachedDevices): IInjector {
			const customEventEmitter = new CustomDeviceEmitter(devices);
			const testInjector = new Yok();
			testInjector.register("injector", testInjector);
			testInjector.register("nsCloudDeviceEmulator", {
				get deviceEmitter() {
					return customEventEmitter;
				}
			});
			testInjector.register("nsCloudServerEmulatorsService", { /* empty */ });
			testInjector.register("mobileHelper", {
				normalizePlatformName: (platform: string) => platform.toLowerCase()
			});

			return testInjector;
		}
github NativeScript / nativescript-cloud / test / services / cloud-emulator-service.ts View on Github external
function createTestInjector(): IInjector {
			const testInjector = new Yok();
			testInjector.register("nsCloudServerRequestService", {
				call: async () => emulatorCredentials
			});
			testInjector.register("fs", {
				exists: () => true,
				readJson: () => ({}),
				writeJson: () => { /* empty */ }
			});
			testInjector.register("nsCloudUploadService", {
				uploadToS3: async (url: string) => url
			});
			testInjector.register("nsCloudDeviceEmulator", { /* empty */ });
			testInjector.register("options", {
				profileDir: "test"
			});
			testInjector.register("nsCloudEulaService", {
github NativeScript / nativescript-cloud / test / commands / cloud-build.ts View on Github external
it("returns the real version of the package", async () => {
		const testInjector = new Yok();
		testInjector.register("fs", FileSystem);
		let message: string = null;
		const loggerInfo = (msg: string) => {
			message = msg;
		};

		testInjector.register("logger", {
			info: loggerInfo
		});

		testInjector.register("nsCloudPackageInfoService", PackageInfoService);
		testInjector.registerCommand("command", CloudLibVersion);

		await testInjector.resolveCommand("command").execute([]);

		const realVersion = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json")).toString()).version;
github NativeScript / nativescript-cli-tests / tests / page_templates / add.js View on Github external
const newPageName = args[0];
    const options = {
        displayName: args[1],
        templateFlavor: appFlavor
    }
    const appPath = args[3];
    tns.nsStarterKitsApplicationService.addPage(newPageName, options, appPath, "next")
    .then(function(details){
        console.log('Details=== ', details)
    })
    .catch(function(err){
        console.error('Error=== ', err)
    })
};

Promise.all(tns.extensibilityService.loadExtensions())
    .then(pageAction, pageAction);
github NativeScript / nativescript-cli-tests / tests / page_templates / add.js View on Github external
const pageAction = () => {
    const args = process.argv.slice(2, 6);
    let appFlavor = '';
    try {
        appFlavor = checkFlavor(args[2]);
    } catch(error) {
        console.error(error);
    }
    
    const newPageName = args[0];
    const options = {
        displayName: args[1],
        templateFlavor: appFlavor
    }
    const appPath = args[3];
    tns.nsStarterKitsApplicationService.addPage(newPageName, options, appPath, "next")
    .then(function(details){
        console.log('Details=== ', details)
    })
    .catch(function(err){
        console.error('Error=== ', err)
    })
};
github NativeScript / nativescript-cli-tests / tests / page_templates / add.js View on Github external
'use strict';

const path = require("path");
const tns = require("nativescript");
tns.settingsService.setSettings({ profileDir: path.join(__dirname, "..", "..") });

const checkFlavor = (flavor) => {
    if (typeof flavor !== "string") {
        return new Error("Flavor fust be string");
    }
    const isAngular= flavor.indexOf("ng") > -1;
    const isTypeScript = flavor.indexOf("ts") > -1;
    const isJs = flavor.indexOf("js") > -1;

    if (isAngular) {
        flavor = "Angular & TypeScript";
        console.log("Flavor === ", flavor);
    } else if (isTypeScript) {
        flavor = "TypeScript";
        console.log("Flavor === ", flavor);
    } else if (isJs) {
github NativeScript / nativescript-cloud / test / commands / eula-command-helper.ts View on Github external
const createTestInjector = (): IInjector => {
		const testInjector = new Yok();
		testInjector.register("nsCloudErrorsService", {
			fail: (message: string, ...args: any[]): never => { throw new Error(message); }
		});

		testInjector.register("logger", {
			printMarkdown: (...args: any[]): void => undefined,
			trace: (formatStr?: any, ...args: any[]): void => undefined,
			info: (formatStr?: any, ...args: any[]): void => undefined,
		});

		testInjector.register("nsCloudEulaService", {
			acceptEula: async (): Promise => undefined,
			getEulaDataWithCache: async (): Promise => ({ url: EulaConstants.eulaUrl, shouldAcceptEula: true })
		});

		testInjector.register("prompter", {
github NativeScript / nativescript-cloud / test / services / version-service.ts View on Github external
const createTestInjector = (cloudConfigurationData?:  ICloudConfigurationData): IInjector => {
		const testInjector = new Yok();
		testInjector.register("logger", {
			trace: (formatStr?: any, ...args: any[]): void => (undefined)
		});
		testInjector.register("httpClient", {});
		testInjector.register("nsCloudConfigurationService", {
			getCloudConfigurationData: () => cloudConfigurationData
		});
		testInjector.register("nsCloudPolyfillService", PolyfillService);
		testInjector.register("projectDataService", {});
		return testInjector;
	};
github NativeScript / nativescript-cloud / test / cloud-operation / communication / communication-channel-factory.ts View on Github external
const createTestInjector = (): IInjector => {
		const testInjector = new Yok();

		testInjector.register("logger", {});
		testInjector.register("nsCloudCommunicationChannelFactory", CommunicationChannelFactory);
		testInjector.register("nsCloudWebSocketFactory", {
			create: (): any => null
		});
		testInjector.register("injector", testInjector);

		return testInjector;
	};
	beforeEach(() => {

nativescript

Command-line interface for building NativeScript projects

Apache-2.0
Latest version published 19 days ago

Package Health Score

80 / 100
Full package analysis