How to use the @nstudio/xplat.prerun 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 / 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 / angular / src / schematics / xplat / index.ts View on Github external
export default function(options: XplatHelpers.Schema) {
  // console.log(`Generating xplat angular support for: ${options.platforms}`);
  const externalChains = XplatAngularHelpers.externalChains(options);

  return chain([
    prerun(options, true),
    // update gitignore to support xplat
    XplatHelpers.updateGitIgnore(),
    // libs
    XplatAngularHelpers.addLibFiles(options),
    (tree: Tree, context: SchematicContext) => {
      if (tree.exists('/libs/scss/_index.scss')) {
        // user may have generated support already
        return noop()(tree, context);
      } else {
        return branchAndMerge(
          mergeWith(
            apply(url(`./_scss_files`), [
              template({
                ...(options as any),
                ...getDefaultTemplateOptions()
              }),
github nstudio / xplat / packages / ionic-angular / src / schematics / xplat / index.ts View on Github external
export default function(options: XplatHelpers.Schema) {
  return chain([
    prerun(options, true),
    (tree: Tree, context: SchematicContext) =>
      externalSchematic(
        '@nstudio/ionic',
        'xplat',
        {
          ...options,
          skipDependentPlatformFiles: true
        },
        { interactive: false }
      ),
    (tree: Tree, context: SchematicContext) => {
      const xplatFolderName = XplatHelpers.getXplatFoldername(
        'ionic',
        'angular'
      );
      // console.log('xplatName:', xplatName);
github nstudio / xplat / packages / electron / src / schematics / application / index.ts View on Github external
);
  } else {
    // TODO: find a way to unit test schematictask runners with install tasks
    packageHandling.push((tree: Tree, context: SchematicContext) => {
      const installPackageTask = context.addTask(new NodePackageInstallTask());

      // console.log('packagesToRunXplat:', packagesToRunXplat);
      context.addTask(
        new RunSchematicTask('@nstudio/electron', 'tools', options),
        [installPackageTask]
      );
    });
  }

  return chain([
    prerun(options),
    XplatHelpers.applyAppNamingConvention(options, 'electron'),
    (tree: Tree, context: SchematicContext) =>
      addAppFiles(options, options.name)(tree, context),
    XplatElectrontHelpers.updateRootDeps(options),
    ...packageHandling,
    XplatElectrontHelpers.addNpmScripts(options),
    (tree: Tree, context: SchematicContext) => {
      // grab the target app configuration
      const workspaceConfig = readWorkspaceJson(tree);
      // find app
      const fullTargetAppName = options.target;
      let targetConfig;
      if (workspaceConfig && workspaceConfig.projects) {
        targetConfig = workspaceConfig.projects[fullTargetAppName];
      }
      if (!targetConfig) {
github nstudio / xplat / packages / web-angular / src / schematics / xplat / index.ts View on Github external
export default function(options: XplatHelpers.Schema) {
  return chain([
    prerun(options, true),
    (tree: Tree, context: SchematicContext) => {
      const xplatFolderName = XplatHelpers.getXplatFoldername('web', 'angular');
      // console.log('xplatName:', xplatName);
      return options.skipDependentPlatformFiles
        ? noop()
        : XplatHelpers.addPlatformFiles(options, xplatFolderName)(
            tree,
            context
          );
    },
    (tree: Tree, context: SchematicContext) => {
      const xplatFolderName = XplatHelpers.getXplatFoldername('web', 'angular');
      if (tree.exists(`/xplat/${xplatFolderName}/scss/_index.scss`)) {
        // may have already generated vanilla web support
        return noop()(tree, context);
      } else {
github nstudio / xplat / packages / ionic / src / schematics / application / index.ts View on Github external
export default function(options: Schema) {
  if (!options.name) {
    throw new SchematicsException(
      missingArgument(
        'name',
        'Provide a name for your Ionic app.',
        'nx g @nstudio/ionic:app name'
      )
    );
  }

  return chain([
    prerun(options),
    // adjust naming convention
    XplatHelpers.applyAppNamingConvention(options, 'ionic'),
    // create app files
    (tree: Tree, context: SchematicContext) =>
      addAppFiles(options, options.name)(tree, context),
    // add root package dependencies
    XplatIonicHelpers.updateRootDeps(options),
    XplatHelpers.addPackageInstallTask(options),
    // add start/clean scripts
    (tree: Tree) => {
      const scripts = {};
      const platformApp = options.name.replace('-', '.');
      const directory = options.directory ? `${options.directory}/` : '';
      // ensure convenient clean script is added for workspace
      scripts[
        `clean`
github nstudio / xplat / packages / electron / src / schematics / ng-add / index.ts View on Github external
export default function(options: XplatHelpers.NgAddSchema) {

  const chains = [];

  if (options.platforms) {
    // running from @nstudio/xplat:init --platforms electron
    chains.push((tree: Tree, context: SchematicContext) =>
    externalSchematic('@nstudio/electron', 'xplat', options));
  } else {
    // running directly with @nstudio/electron, just add deps
    chains.push(XplatElectrontHelpers.updateRootDeps(options));
    chains.push(addInstallTask(options));
  }
  return chain([
    prerun(options, true),
    ...chains
  ]);
}
github nstudio / xplat / packages / nativescript-angular / src / schematics / application / index.ts View on Github external
if (!options.name) {
    throw new SchematicsException(
      missingArgument(
        'name',
        'Provide a name for your NativeScript app.',
        'nx g @nstudio/nativescript-angular:app name'
      )
    );
  }
  if (options.setupSandbox) {
    // always setup routing with sandbox
    options.routing = true;
  }

  return chain([
    prerun(options),
    // adjust naming convention
    XplatHelpers.applyAppNamingConvention(options, 'nativescript'),
    // use xplat or not
    options.useXplat
      ? externalSchematic('@nstudio/nativescript-angular', 'xplat', options)
      : noop(),
    // create app files
    (tree: Tree, context: SchematicContext) =>
      addAppFiles(options, options.name, options.useXplat ? '' : 'skipxplat'),
    // add features
    (tree: Tree, context: SchematicContext) =>
      options.routing && options.useXplat
        ? addAppFiles(options, options.name, 'routing')(tree, context)
        : noop()(tree, context),
    // add app resources
    (tree: Tree, context: SchematicContext) => {
github nstudio / xplat / packages / nativescript / src / schematics / application / index.ts View on Github external
if (!options.name) {
    throw new SchematicsException(
      missingArgument(
        'name',
        'Provide a name for your NativeScript app.',
        'nx g @nstudio/nativescript:app name'
      )
    );
  }
  // if (options.setupSandbox) {
  //   // always setup routing with sandbox
  //   options.routing = true;
  // }

  return chain([
    prerun(options),
    // adjust naming convention
    XplatHelpers.applyAppNamingConvention(options, 'nativescript'),
    // create app files
    (tree: Tree, context: SchematicContext) =>
      addAppFiles(options, options.name),
    // add app resources
    (tree: Tree, context: SchematicContext) =>
      // inside closure to ensure it uses the modifed options.name from applyAppNamingConvention
      externalSchematic(
        '@nstudio/nativescript',
        'app-resources',
        {
          path: `apps/${options.name}`
        },
        { interactive: false }
      )(tree, context),
github nstudio / xplat / packages / nativescript / src / schematics / xplat / index.ts View on Github external
export default function(options: XplatHelpers.Schema) {
  return chain([
    prerun(options),
    options.skipDependentPlatformFiles
      ? noop()
      : XplatHelpers.addPlatformFiles(options, 'nativescript'),
    XplatNativeScriptHelpers.updateRootDeps(options),
    XplatNativeScriptHelpers.updatePrettierIgnore()
  ]);
}