Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ionic/angular-standalone-codemods

Package Overview
Dependencies
Maintainers
27
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ionic/angular-standalone-codemods - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

125

dist/index.js

@@ -30,3 +30,3 @@ #!/usr/bin/env node

var import_utils_terminal = require("@ionic/utils-terminal");
var import_ts_morph6 = require("ts-morph");
var import_ts_morph7 = require("ts-morph");
var import_node_fs2 = require("fs");

@@ -424,2 +424,17 @@ var import_node_process = require("process");

];
var migrateProvideIonicAngularImportDeclarations = (sourceFile) => {
const importDeclaration = sourceFile.getImportDeclaration("@ionic/angular");
if (!importDeclaration) {
return;
}
importDeclaration.setModuleSpecifier("@ionic/angular/standalone");
const namedImports = importDeclaration.getNamedImports();
const importSpecifier = namedImports.find(
(n) => n.getName() === "IonicModule"
);
if (importSpecifier) {
importSpecifier.remove();
}
importDeclaration.addNamedImport("provideIonicAngular");
};

@@ -775,5 +790,8 @@ // src/angular/utils/string-utils.ts

}
const importProvidersFromFunctionCall = providersArray.getFirstChildByKind(
import_ts_morph5.SyntaxKind.CallExpression
);
const importProvidersFromFunctionCall = providersArray.getChildrenOfKind(import_ts_morph5.SyntaxKind.CallExpression).find((callExpression) => {
const identifier = callExpression.getFirstChildByKind(
import_ts_morph5.SyntaxKind.Identifier
);
return identifier !== void 0 && identifier.getText() === "importProvidersFrom";
});
if (importProvidersFromFunctionCall === void 0) {

@@ -816,3 +834,3 @@ return;

providersArray.formatText();
migrateIonicAngularImportDeclarations(sourceFile);
migrateProvideIonicAngularImportDeclarations(sourceFile);
return await saveFileChanges(sourceFile, cliOptions);

@@ -822,17 +840,2 @@ }

};
function migrateIonicAngularImportDeclarations(sourceFile) {
const importDeclaration = sourceFile.getImportDeclaration("@ionic/angular");
if (!importDeclaration) {
return;
}
importDeclaration.setModuleSpecifier("@ionic/angular/standalone");
const namedImports = importDeclaration.getNamedImports();
const importSpecifier = namedImports.find(
(n) => n.getName() === "IonicModule"
);
if (importSpecifier) {
importSpecifier.remove();
}
importDeclaration.addNamedImport("provideIonicAngular");
}

@@ -881,2 +884,79 @@ // src/angular/migrations/standalone/0005-migrate-angular-json-assets.ts

// src/angular/migrations/standalone/0006-migrate-angular-app-config.ts
var import_ts_morph6 = require("ts-morph");
var migrateAngularAppConfig = async (project, cliOptions) => {
const sourceFile = project.getSourceFiles().find((sourceFile2) => sourceFile2.getFilePath().endsWith("app.config.ts"));
if (sourceFile === void 0) {
return;
}
const appConfigVariableStatement = sourceFile.getVariableStatements().find((variableStatement) => {
const declarationList = variableStatement.getDeclarationList();
const variableDeclaration = declarationList.getDeclarations()[0];
return variableDeclaration.getName() === "appConfig";
});
if (appConfigVariableStatement === void 0) {
return;
}
const appConfigVariableStatementDeclarationList = appConfigVariableStatement.getDeclarationList();
const appConfigVariableDeclaration = appConfigVariableStatementDeclarationList.getDeclarations()[0];
const appConfigInitializer = appConfigVariableDeclaration.getInitializer();
if (appConfigInitializer === void 0) {
return;
}
const appConfigObjectLiteralExpression = appConfigInitializer;
const providersPropertyAssignment = appConfigObjectLiteralExpression.getProperty("providers");
if (providersPropertyAssignment === void 0) {
return;
}
const providersArray = providersPropertyAssignment.getFirstChildByKind(
import_ts_morph6.SyntaxKind.ArrayLiteralExpression
);
if (providersArray === void 0) {
return;
}
const importProvidersFromFunctionCall = providersArray.getChildrenOfKind(import_ts_morph6.SyntaxKind.CallExpression).find((callExpression) => {
const identifier = callExpression.getFirstChildByKind(
import_ts_morph6.SyntaxKind.Identifier
);
return identifier !== void 0 && identifier.getText() === "importProvidersFrom";
});
if (importProvidersFromFunctionCall === void 0) {
return;
}
const importProvidersFromFunctionCallIdentifier = importProvidersFromFunctionCall.getFirstChildByKind(import_ts_morph6.SyntaxKind.Identifier);
if (importProvidersFromFunctionCallIdentifier === void 0) {
return;
}
if (importProvidersFromFunctionCallIdentifier.getText() !== "importProvidersFrom") {
return;
}
const importProvidersFromFunctionCallArguments = importProvidersFromFunctionCall.getArguments();
if (importProvidersFromFunctionCallArguments.length === 0) {
return;
}
const importProvidersFromFunctionCallIonicModuleForRootCallExpression = importProvidersFromFunctionCallArguments.find((argument) => {
return argument.getText().includes("IonicModule.forRoot");
});
if (importProvidersFromFunctionCallIonicModuleForRootCallExpression === void 0) {
return;
}
if (importProvidersFromFunctionCallIonicModuleForRootCallExpression.isKind(
import_ts_morph6.SyntaxKind.CallExpression
)) {
const importProvidersFromFunctionCallIonicModuleForRootCallExpressionArguments = importProvidersFromFunctionCallIonicModuleForRootCallExpression.getArguments();
const ionicConfigObjectLiteralExpression = importProvidersFromFunctionCallIonicModuleForRootCallExpressionArguments[0];
const ionicConfigValue = ionicConfigObjectLiteralExpression ? ionicConfigObjectLiteralExpression.getText() : "";
providersArray.addElement(`provideIonicAngular(${ionicConfigValue})`);
importProvidersFromFunctionCall.removeArgument(
importProvidersFromFunctionCallIonicModuleForRootCallExpression
);
if (importProvidersFromFunctionCall.getArguments().length === 0) {
providersArray.removeElement(importProvidersFromFunctionCall);
}
providersArray.formatText();
migrateProvideIonicAngularImportDeclarations(sourceFile);
return await saveFileChanges(sourceFile, cliOptions);
}
};
// src/angular/migrations/standalone/index.ts

@@ -899,2 +979,3 @@ var runStandaloneMigration = async ({

await migrateAngularJsonAssets(project, cliOptions);
await migrateAngularAppConfig(project, cliOptions);
spinner3.stop(`Project migration at ${dir} completed successfully.`);

@@ -991,7 +1072,7 @@ import_prompts3.log.success(

if ((0, import_node_fs2.existsSync)(`${cli.dir}/tsconfig.json`)) {
project = new import_ts_morph6.Project({
project = new import_ts_morph7.Project({
tsConfigFilePath: `${cli.dir}/tsconfig.json`
});
} else {
project = new import_ts_morph6.Project();
project = new import_ts_morph7.Project();
}

@@ -998,0 +1079,0 @@ const s = (0, import_prompts4.spinner)();

2

package.json
{
"name": "@ionic/angular-standalone-codemods",
"version": "0.0.6",
"version": "0.0.7",
"dependencies": {

@@ -5,0 +5,0 @@ "@angular-eslint/template-parser": "^16.1.2",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc