Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)) {
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()
}),
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);
);
} 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) {
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 {
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`
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
]);
}
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) => {
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),
export default function(options: XplatHelpers.Schema) {
return chain([
prerun(options),
options.skipDependentPlatformFiles
? noop()
: XplatHelpers.addPlatformFiles(options, 'nativescript'),
XplatNativeScriptHelpers.updateRootDeps(options),
XplatNativeScriptHelpers.updatePrettierIgnore()
]);
}