How to use the @nstudio/xplat.jsonParse function in @nstudio/xplat

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 / 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 / schematics / helpers / index.spec.ts View on Github external
expect(
      fileContent.indexOf('@applitools/eyes-cypress/commands')
    ).toBeGreaterThanOrEqual(0);

    filePath = '/apps/web-foo-e2e/src/plugins/index.ts';
    fileContent = getFileContent(tree, filePath);
    // console.log(fileContent);

    expect(
      fileContent.indexOf(`require('@applitools/eyes-cypress')(module);`)
    ).toBeGreaterThanOrEqual(0);

    fileContent = getFileContent(tree, cypressJsonPath);
    // console.log(fileContent);
    cypressJson = jsonParse(fileContent);
    expect(cypressJson.supportFile).toBe(`./src/support/index.js`);

    filePath = '/apps/web-foo-e2e/src/integration/app.spec.ts';
    fileContent = getFileContent(tree, filePath);
    // console.log(fileContent);

    expect(fileContent.indexOf(`eyesOpen`)).toBeGreaterThanOrEqual(0);
  });
github nstudio / xplat / packages / 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 };
    options.platforms = 'electron';

    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();
  });
github nstudio / xplat / packages / electron-angular / src / schematics / application / index.spec.ts View on Github external
// console.log(checkFile);
    expect(checkFile.indexOf(`"name": "foo"`)).toBeGreaterThanOrEqual(0);

    expect(
      files.indexOf('/tools/electron/postinstall.js')
    ).toBeGreaterThanOrEqual(0);
    expect(files.indexOf('/tools/web/postinstall.js')).toBeGreaterThanOrEqual(
      0
    );

    checkPath = '/package.json';
    expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);

    checkFile = getFileContent(tree, checkPath);
    // console.log(checkFile);
    const packageData: any = jsonParse(checkFile);
    expect(packageData.scripts['postinstall']).toBeDefined();
    expect(packageData.scripts['postinstall.electron']).toBeDefined();
    expect(packageData.scripts['postinstall.web']).toBeDefined();
    expect(packageData.scripts['build.electron.foo']).toBeDefined();
    expect(packageData.scripts['build.electron.foo.local']).toBeDefined();
    expect(packageData.scripts['build.electron.foo.linux']).toBeDefined();
    expect(packageData.scripts['build.electron.foo.windows']).toBeDefined();
    expect(packageData.scripts['build.electron.foo.mac']).toBeDefined();
    expect(packageData.scripts['prepare.electron.foo']).toBeDefined();
    expect(packageData.scripts['serve.electron.foo.target']).toBeDefined();
    expect(packageData.scripts['serve.electron.foo']).toBeDefined();
    expect(packageData.scripts['start.electron.foo']).toBeDefined();

    // check target web app for supporting files
    checkPath = '/apps/web-viewer/src/app/app.electron.module.ts';
    expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);
github nstudio / xplat / packages / 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 };
    options.platforms = 'ionic';
    options.framework = 'angular';

    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();
  });
github nstudio / xplat / packages / electron / src / schematics / application / index.spec.ts View on Github external
// console.log(checkFile);
    expect(checkFile.indexOf(`"name": "foo"`)).toBeGreaterThanOrEqual(0);

    // expect(
    //   files.indexOf('/tools/electron/postinstall.js')
    // ).toBeGreaterThanOrEqual(0);
    // expect(files.indexOf('/tools/web/postinstall.js')).toBeGreaterThanOrEqual(
    //   0
    // );

    checkPath = '/package.json';
    expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);

    checkFile = getFileContent(tree, checkPath);
    // console.log(checkFile);
    const packageData: any = jsonParse(checkFile);
    expect(packageData.scripts['postinstall']).toBeDefined();
    expect(packageData.scripts['postinstall.electron']).toBeDefined();
    expect(packageData.scripts['postinstall.web']).toBeDefined();
    expect(packageData.scripts['build.electron.foo']).toBeDefined();
    expect(packageData.scripts['build.electron.foo.local']).toBeDefined();
    expect(packageData.scripts['build.electron.foo.linux']).toBeDefined();
    expect(packageData.scripts['build.electron.foo.windows']).toBeDefined();
    expect(packageData.scripts['build.electron.foo.mac']).toBeDefined();
    expect(packageData.scripts['prepare.electron.foo']).toBeDefined();
    expect(packageData.scripts['serve.electron.foo.target']).toBeDefined();
    expect(packageData.scripts['serve.electron.foo']).toBeDefined();
    expect(packageData.scripts['start.electron.foo']).toBeDefined();

    // should *NOT* generate angular specific files
    expect(
      tree.exists('/apps/web-viewer/src/app/app.electron.module.ts')