How to use @nstudio/xplat - 10 common examples

To help you get started, we’ve selected a few @nstudio/xplat 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 nstudio / xplat / packages / nativescript / src / schematics / xplat / index.spec.ts View on Github external
it('should create default xplat support for nativescript only', async () => {
    const options: XplatHelpers.Schema = { ...defaultOptions };

    appTree.create('.prettierignore', '# sample');
    const tree = await runSchematic('xplat', options, appTree);
    expect(tree.exists('/xplat/web/index.ts')).toBeFalsy();
    expect(tree.exists('/xplat/nativescript/index.ts')).toBeTruthy();
    const packagePath = '/package.json';
    const packageFile = jsonParse(getFileContent(tree, packagePath));
    const hasNativeScript = packageFile.dependencies[`tns-core-modules`];
    expect(hasNativeScript).not.toBeUndefined();

    const prettier = getFileContent(tree, '.prettierignore');
    // console.log('prettier:', prettier);
    expect(
      prettier.indexOf('**/xplat/nativescript*/plugins/**/*')
    ).toBeGreaterThan(0);
  });
});
github nstudio / xplat / packages / angular / src / schematics / helpers / applitools / index.ts View on Github external
)
    );
    // ensure supportFile points to updates
    const cypressConfigPath = `/apps/${options.target}-e2e/cypress.json`;
    const cypressConfig = getJsonFromFile(tree, cypressConfigPath);
    // console.log('cypressConfig:', cypressConfig);
    // plugin path is always defined so ensure support matches
    const pluginsFilePath = cypressConfig.pluginsFile;
    // console.log('pluginsFilePath:', pluginsFilePath);
    const outputPath = pluginsFilePath.split('plugins/')[0];
    cypressConfig.supportFile = `${outputPath}support/index.js`;
    // console.log('cypressConfig.supportFile:', cypressConfig.supportFile);
    helperChains.push(updateJsonFile(tree, cypressConfigPath, cypressConfig));

    // Add applitools modules
    const packageJson = getJsonFromFile(tree, 'package.json');
    packageJson.devDependencies = packageJson.devDependencies || {};
    packageJson.devDependencies['@applitools/eyes-cypress'] = '^3.7.1';
    helperChains.push(updateJsonFile(tree, 'package.json', packageJson));

    // update sample test
    helperChains.push(
      createOrUpdate(
        tree,
        `/apps/${options.target}-e2e/src/integration/app.spec.ts`,
        updateSampleTest()
      )
    );
  };
}
github nstudio / xplat / packages / web-angular / src / schematics / xplat / index.spec.ts View on Github external
it('should create default xplat support for web only', async () => {
    const options: XplatHelpers.Schema = { ...defaultOptions };

    const tree = await runSchematic('xplat', options, appTree);
    expect(tree.exists('/xplat/web/index.ts')).toBeTruthy();
    expect(tree.exists('/xplat/nativescript/index.ts')).toBeFalsy();
    let filePath = '/tsconfig.json';
    let fileContent = jsonParse(getFileContent(tree, filePath));
    // console.log(fileContent);
    expect(fileContent.compilerOptions.paths['@testing/web']).toBeTruthy();
    expect(fileContent.compilerOptions.paths['@testing/web/*']).toBeTruthy();
    filePath = '/package.json';
    fileContent = jsonParse(getFileContent(tree, filePath));
    // const hasScss = packageFile.dependencies[`@testing/scss`];
    // expect(hasScss).not.toBeUndefined();
    // should not include these root packages
    const hasNativeScript = fileContent.dependencies[`nativescript-angular`];
    expect(hasNativeScript).toBeUndefined();
    filePath = '/xplat/web/.xplatframework';
    fileContent = getFileContent(tree, filePath);
    // console.log(fileContent);
    expect(fileContent.indexOf('angular')).toBeGreaterThanOrEqual(0);
  });
github nstudio / xplat / packages / electron-angular / src / schematics / xplat / index.spec.ts View on Github external
it('should create default xplat support for electron which should always include web as well', async () => {
    const options: XplatHelpers.Schema = { ...defaultOptions };

    const tree = await runSchematic('xplat', options, appTree);
    const files = tree.files;
    expect(files.indexOf('/xplat/web/index.ts')).toBeGreaterThanOrEqual(0);
    expect(files.indexOf('/xplat/electron/index.ts')).toBeGreaterThanOrEqual(0);
    expect(
      files.indexOf('/xplat/nativescript/index.ts')
    ).toBeGreaterThanOrEqual(-1);
    const packagePath = '/package.json';
    const packageFile = jsonParse(getFileContent(tree, packagePath));
    // const hasScss = packageFile.dependencies[`@testing/scss`];
    // expect(hasScss).not.toBeUndefined();
    // const hasWebScss = packageFile.dependencies[`@testing/web-scss`];
    // expect(hasWebScss).not.toBeUndefined();
    // should not include these root packages
    const hasNativeScript = packageFile.dependencies[`nativescript-angular`];
    expect(hasNativeScript).toBeUndefined();
    const hasElectron = packageFile.devDependencies[`electron`];
    expect(hasElectron).toBeDefined();
    let filePath = '/tsconfig.json';
    let fileContent = jsonParse(getFileContent(tree, filePath));
    // console.log(fileContent);
    expect(fileContent.compilerOptions.paths['@testing/electron']).toBeTruthy();
    expect(
      fileContent.compilerOptions.paths['@testing/electron/*']
    ).toBeTruthy();
github nstudio / xplat / packages / nativescript-angular / src / schematics / xplat / index.spec.ts View on Github external
it('should create default xplat support for nativescript-angular only', async () => {
    const options: XplatHelpers.Schema = { ...defaultOptions };

    const tree = await runSchematic('xplat', options, appTree);
    // const files = tree.files;
    expect(tree.exists('/xplat/web/index.ts')).toBeFalsy();
    expect(tree.exists('/xplat/nativescript/index.ts')).toBeTruthy();
    expect(tree.exists('/xplat/nativescript/core/index.ts')).toBeTruthy();
    expect(
      tree.exists('/xplat/nativescript/features/ui/index.ts')
    ).toBeTruthy();
    const packagePath = '/package.json';
    const packageFile = jsonParse(getFileContent(tree, packagePath));
    // console.log('packageFile:', packageFile);
    expect(packageFile.dependencies[`tns-core-modules`]).not.toBeUndefined();
    expect(
      packageFile.dependencies[`nativescript-angular`]
    ).not.toBeUndefined();
    expect(
      packageFile.dependencies[`nativescript-ngx-fonticon`]
    ).not.toBeUndefined();
    expect(
      packageFile.devDependencies[`tns-platform-declarations`]
    ).not.toBeUndefined();
    let filePath = '/tsconfig.json';
    let fileContent = jsonParse(getFileContent(tree, filePath));
    // console.log(fileContent);
    expect(
      fileContent.compilerOptions.paths['@testing/nativescript']
github nstudio / xplat / packages / ionic-angular / src / schematics / xplat / index.spec.ts View on Github external
xit('should create default xplat support for ionic which should always include web as well', async () => {
    const options: XplatHelpers.Schema = { ...defaultOptions };

    const tree = await runSchematic('xplat', options, appTree);
    const files = tree.files;
    expect(files.indexOf('/xplat/web/index.ts')).toBeGreaterThanOrEqual(0);
    expect(files.indexOf('/xplat/ionic/index.ts')).toBeGreaterThanOrEqual(0);
    expect(
      files.indexOf('/xplat/nativescript/index.ts')
    ).toBeGreaterThanOrEqual(-1);
    const packagePath = '/package.json';
    const packageFile = jsonParse(getFileContent(tree, packagePath));
    // const hasScss = packageFile.dependencies[`@testing/scss`];
    // expect(hasScss).not.toBeUndefined();
    const hasWebScss = packageFile.dependencies[`@testing/web-scss`];
    expect(hasWebScss).not.toBeUndefined();
    // should not include these root packages
    const hasNativeScript = packageFile.dependencies[`nativescript-angular`];
    expect(hasNativeScript).toBeUndefined();
    let filePath = '/tsconfig.json';
    let fileContent = jsonParse(getFileContent(tree, filePath));
    // console.log(fileContent);
    expect(fileContent.compilerOptions.paths['@testing/ionic']).toBeTruthy();
    expect(fileContent.compilerOptions.paths['@testing/ionic/*']).toBeTruthy();
    filePath = '/xplat/ionic/.xplatframework';
    fileContent = getFileContent(tree, filePath);
    // console.log(fileContent);
    expect(fileContent.indexOf('angular')).toBeGreaterThanOrEqual(0);
github nstudio / xplat / packages / nativescript-angular / src / schematics / xplat / index.spec.ts View on Github external
it('when default framework is set, can still create base platform support', async () => {
    appTree = Tree.empty();
    appTree = createEmptyWorkspace(appTree);
    let options: XplatHelpers.Schema = { ...defaultOptions };
    options.framework = 'angular';

    let tree = await runSchematic('xplat', options, appTree);
    expect(tree.exists('/xplat/nativescript/index.ts')).toBeTruthy();
    let filePath = '/tsconfig.json';
    let fileContent = jsonParse(getFileContent(tree, filePath));
    // console.log(fileContent);
    expect(
      fileContent.compilerOptions.paths['@testing/nativescript']
    ).toBeTruthy();
    expect(
      fileContent.compilerOptions.paths['@testing/nativescript/*']
    ).toBeTruthy();

    expect(() => runSchematicSync('xplat', defaultOptions, tree)).toThrow(
      `You currently have "angular" set as your default frontend framework and have already generated xplat support for "nativescript". A command is coming soon to auto reconfigure your workspace to later add baseline platform support for those which have previously been generated prepaired with a frontend framework.`
    );
  });
});
github nstudio / xplat / packages / angular / src / utils / xplat.ts View on Github external
export function platformGenerator(
    options: XplatComponentHelpers.Schema,
    platform: PlatformTypes
  ) {
    const chains: Array = [prerun()];
    const componentSettings = XplatComponentHelpers.prepare(options);

    if (options.onlyProject) {
      for (const projectName of componentSettings.projectNames) {
        const projectParts = projectName.split('-');
        const platPrefix = projectParts[0];
        const platSuffix = projectParts.pop();
        if (platPrefix === platform || platSuffix === platform) {
          const appDir = platform === 'web' ? '/app' : '';
          const prefixPath = `apps/${projectName}/src${appDir}`;
          const featurePath = `${prefixPath}/features/${componentSettings.featureName}`;
          const featureModulePath = `${featurePath}/${componentSettings.featureName}.module.ts`;
          const barrelIndex = `${featurePath}/components/index.ts`;
          // console.log('will adjustProject:', projectName);
          chains.push((tree: Tree, context: SchematicContext) => {
            if (!tree.exists(featureModulePath)) {
github nstudio / xplat / packages / nativescript-angular / src / schematics / xplat / index.spec.ts View on Github external
it('should create default xplat support with framework suffix when not specifying default', async () => {
    appTree = Tree.empty();
    appTree = createEmptyWorkspace(appTree);
    const options: XplatHelpers.Schema = { ...defaultOptions };

    const tree = await runSchematic('xplat', options, appTree);
    expect(tree.exists('/xplat/nativescript-angular/index.ts')).toBeTruthy();
    const filePath = '/tsconfig.json';
    const fileContent = jsonParse(getFileContent(tree, filePath));
    // console.log(fileContent);
    expect(
      fileContent.compilerOptions.paths['@testing/nativescript-angular']
    ).toBeTruthy();
    expect(
      fileContent.compilerOptions.paths['@testing/nativescript-angular/*']
    ).toBeTruthy();
  });
github nstudio / xplat / packages / web-angular / src / schematics / xplat / index.spec.ts View on Github external
it('should create default xplat support with framework suffix when not specifying default', async () => {
    appTree = Tree.empty();
    appTree = createEmptyWorkspace(appTree);
    const options: XplatHelpers.Schema = { ...defaultOptions };

    const tree = await runSchematic('xplat', options, appTree);
    expect(tree.exists('/xplat/web-angular/index.ts')).toBeTruthy();
    const filePath = '/tsconfig.json';
    const fileContent = jsonParse(getFileContent(tree, filePath));
    // console.log(fileContent);
    expect(
      fileContent.compilerOptions.paths['@testing/web-angular']
    ).toBeTruthy();
    expect(
      fileContent.compilerOptions.paths['@testing/web-angular/*']
    ).toBeTruthy();
  });
});