Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 3 additions & 64 deletions packages/devextreme-cli/src/applications/application.angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,40 +63,6 @@ function localPackageExists(packageName) {
return false;
}

function getLocalCollectionPath(packageName) {
const nodeModulesPath = path.join(process.cwd(), 'node_modules', packageName, 'src', 'collection.json');
if(fs.existsSync(nodeModulesPath)) {
return nodeModulesPath;
}
return null;
}

function getCollectionPath(packageName) {
const localPath = getLocalCollectionPath(packageName);
if(localPath) {
return localPath;
}

try {
const packageJsonPath = require.resolve(`${packageName}/package.json`);
const collectionPath = path.join(path.dirname(packageJsonPath), 'src', 'collection.json');
if(fs.existsSync(collectionPath)) {
return collectionPath;
}
} catch(e) {}

return null;
}

function schematicsCliExists() {
try {
require.resolve('@angular-devkit/schematics-cli/package.json');
return true;
} catch(e) {
return false;
}
}

const hasSutableNgCli = async() => {
const localVersion = ngVersion.getLocalNgVersion();

Expand Down Expand Up @@ -189,44 +155,17 @@ const addView = (viewName, options) => {

const migrateConfigComponents = async(options = {}) => {
const collectionName = 'devextreme-schematics';
const collectionPath = getCollectionPath(collectionName);

if(!collectionPath) {
const prompts = require('prompts');

console.log(`\nRequired package is missing: '${collectionName}'`);

const response = await prompts({
type: 'confirm',
name: 'install',
message: `Would you like to install '${collectionName}@${schematicsVersion}' in the npm cache?`,
initial: true
});

if(!response.install) {
console.log('Migration was canceled.');
process.exit(1);
}
}

const schematicOptions = {
...options
};

const hasSchematicsCli = schematicsCliExists();
const commandArguments = ['--yes'];

if(!hasSchematicsCli) {
commandArguments.push('-p', '@angular-devkit/schematics-cli');
}

if(!collectionPath) {
commandArguments.push('-p', `${collectionName}@${schematicsVersion}`);
}
commandArguments.push('-p', '@angular-devkit/schematics-cli');
commandArguments.push('-p', `${collectionName}@${schematicsVersion}`);

const collectionSpecifier = collectionPath
? `${collectionPath.replace(/\\/g, '/')}:migrate-config-components`
: `${collectionName}:migrate-config-components`;
const collectionSpecifier = `${collectionName}:migrate-config-components`;

commandArguments.push('schematics', collectionSpecifier);

Expand Down
Loading