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

azd-infra

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

azd-infra - npm Package Compare versions

Comparing version 1.1.7 to 1.1.8

5

lib/commands/add.js
import { promises as fs } from 'node:fs';
import path from 'node:path';
import { posix as path } from 'node:path';
import createDebug from 'debug';
import chalk from 'chalk';
import { getBicepCoreTemplates, getBicepDependencyInfo } from '../core/index.js';
import { askForConfirmation, cloneAzdRepository, ensureDirectory, selectMany } from '../util/index.js';
import { askForConfirmation, cloneAzdRepository, convertPathToPosix, ensureDirectory, selectMany } from '../util/index.js';
import { AZD_BICEP_PATH, AZD_INFRA_PATH } from '../constants.js';
const debug = createDebug('add');
export async function add(targetPath, options) {
targetPath = convertPathToPosix(targetPath);
debug('Running command with:', { targetPath, options });

@@ -11,0 +12,0 @@ console.info('Retrieving latest core templates...');

import { promises as fs } from 'node:fs';
import path from 'node:path';
import { posix as path } from 'node:path';
import createDebug from 'debug';
import chalk from 'chalk';
import { getProjectInfraInfo, getBicepDependencyInfo, dependencyUsedBy } from '../core/index.js';
import { askForConfirmation, checkRepositoryDirty, cloneAzdRepository, pathExists, removeFirstPosixPathSegment } from '../util/index.js';
import { askForConfirmation, checkRepositoryDirty, cloneAzdRepository, convertPathToPosix, pathExists, removeFirstPosixPathSegment } from '../util/index.js';
import { AZD_BICEP_CORE_PATH, AZD_BICEP_PATH, AZD_INFRA_PATH } from '../constants.js';
const debug = createDebug('update');
export async function fix(targetPath, options) {
targetPath = convertPathToPosix(targetPath);
debug('Running command with:', { targetPath, options });

@@ -11,0 +12,0 @@ console.info('Checking your infrastructure for issues...');

import { promises as fs } from 'node:fs';
import path from 'node:path';
import { posix as path } from 'node:path';
import createDebug from 'debug';
import chalk from 'chalk';
import { getProjectInfraInfo } from '../core/index.js';
import { askForConfirmation, cloneAzdRepository, readFile, normalizeContent, checkRepositoryDirty } from '../util/index.js';
import { askForConfirmation, cloneAzdRepository, readFile, normalizeContent, checkRepositoryDirty, convertPathToPosix } from '../util/index.js';
import { AZD_BICEP_PATH, AZD_INFRA_PATH } from '../constants.js';

@@ -16,2 +16,3 @@ const debug = createDebug('update');

export async function update(targetPath, options) {
targetPath = convertPathToPosix(targetPath);
debug('Running command with:', { targetPath, options });

@@ -18,0 +19,0 @@ console.info('Checking your infrastructure for updates...');

17

lib/core/bicep.js

@@ -1,6 +0,6 @@

import path from 'node:path';
import { posix as path } from 'node:path';
import createDebug from 'debug';
import glob from 'fast-glob';
import { AZD_BICEP_CORE_GLOBS, AZD_BICEP_PATH, AZD_INFRA_PATH } from '../constants.js';
import { deepClone, pathExists, readFile } from '../util/index.js';
import { convertPathToPosix, deepClone, pathExists, readFile } from '../util/index.js';
import { isDependencyUsed } from './dependency.js';

@@ -10,3 +10,6 @@ const debug = createDebug('bicep');

export async function getBicepDependencyInfo(files, basePath = AZD_INFRA_PATH) {
const bicepFiles = files.filter((file) => file.endsWith('.bicep')).map((file) => path.join(basePath, file));
const bicepFiles = files
.filter((file) => file.endsWith('.bicep'))
.map((file) => convertPathToPosix(file))
.map((file) => path.join(basePath, file));
const deps = {

@@ -21,3 +24,3 @@ graph: {},

while (unresolvedFiles.size > 0) {
const file = path.posix.normalize(unresolvedFiles.values().next().value);
const file = path.normalize(unresolvedFiles.values().next().value);
// Check for missing files

@@ -58,3 +61,3 @@ if (!(await pathExists(file))) {

}
if (!isDependencyUsed(file, usedGraph) && !/main(\..+)?\.bicep$/.test(file)) {
if (!isDependencyUsed(file, usedGraph) && !file.endsWith('main.bicep')) {
debug(`Found new unused dependency: ${file}`);

@@ -75,4 +78,4 @@ unused.add(file);

while ((match = bicepModuleRegex.exec(content)) !== null) {
const modulePath = path.posix.join(path.posix.dirname(file), match[1]);
dependencies.push(path.posix.normalize(modulePath));
const modulePath = path.join(path.dirname(file), match[1]);
dependencies.push(path.normalize(modulePath));
debug(`Found dependency in file ${file}: ${modulePath}`);

@@ -79,0 +82,0 @@ }

@@ -1,2 +0,2 @@

import path from 'node:path';
import { posix as path } from 'node:path';
import createDebug from 'debug';

@@ -3,0 +3,0 @@ import glob from 'fast-glob';

@@ -10,1 +10,2 @@ export type PackageJson = Record<string, any> & {

export declare function removeFirstPosixPathSegment(filePath: string): string;
export declare function convertPathToPosix(filePath: string): string;

@@ -26,1 +26,4 @@ import { join } from 'node:path';

}
export function convertPathToPosix(filePath) {
return filePath.replaceAll('\\', '/');
}
import os from 'node:os';
import path from 'node:path';
import { posix as path } from 'node:path';
import { promises as fs } from 'node:fs';

@@ -7,2 +7,3 @@ import createDebug from 'debug';

import { runCommand } from './command.js';
import { convertPathToPosix } from './file.js';
const debug = createDebug('repository');

@@ -25,3 +26,3 @@ export async function isRepositoryDirty() {

export async function cloneAzdRepository() {
const azdPath = path.join(os.tmpdir(), 'azd');
const azdPath = convertPathToPosix(path.join(os.tmpdir(), 'azd'));
try {

@@ -28,0 +29,0 @@ debug('Cloning azd repo to:', azdPath);

{
"name": "azd-infra",
"version": "1.1.7",
"version": "1.1.8",
"description": "Manages your Azure Developer CLI projects' infrastructure",

@@ -5,0 +5,0 @@ "type": "module",

@@ -10,10 +10,12 @@ # 🏗 azd-infra

> Command line tool to manage your [Azure Developer CLI (AZD)](https://aka.ms/azd) projects' infrastructure.
Command line tool to manage your [Azure Developer CLI (AZD)](https://aka.ms/azd) projects' infrastructure.
> [!NOTE]
> Only Bicep templates are supported for now.
## Usage
You need [Node.js v20+](https://nodejs.org) and git installed on your machine to use this tool.
You can either install the CLI globally:
You can either install it globally:
```bash

@@ -26,5 +28,14 @@ npm install -g azd-infra

```bash
npx azd-infra <command>
npx azd-infra@latest <command>
```
> ![!TIP]
> The quickest way to get started is to run the following command in your project's root folder:
>
> ```bash
> npx azd-infra@latest refresh
> ```
>
> This will interactively update your project's infrastructure with the latest AZD core templates and fix any missing or unused templates.
## Available commands

@@ -39,1 +50,33 @@

### `azd-infra add`
This command will perform the following tasks:
1. Clone the latest version of the AZD repository in a temporary folder.
2. Ask you to select the templates you want to add to your infrastructure.
3. Resolve the dependencies of the selected templates
4. Ask you to confirm the changes
5. Copy the selected templates to your infrastructure folder.
### `azd-infra update`
This command will perform the following tasks:
1. Clone the latest version of the AZD repository in a temporary folder.
2. Scan your project's infrastructure folder and compare `core` templates with their latest version.
3. List each core template of your project to show you its status:
- `current`: if the template is up to date
- `update`: if a newer version available
- `missing`: if no matching file existing in latest core templates. This usually happens when a template has been renamed or removed.
4. Ask you to confirm the changes
5. Update the templates in your infrastructure folder. Missing templates will be left untouched.
### `azd-infra fix`
This command will perform the following tasks:
1. Scan your project's infrastructure folder and build a dependency graph of all resources.
2. List missing referenced and unused templates
3. Ask you to confirm the changes
4. Remove unused templates and add missing templates to your infrastructure folder.
### `azd-infra refresh`
This command will run `update` and `fix` in sequence. This is the recommended command to keep your infrastructure up to date, as sometimes updating a template can introduce new dependencies that will be detected and fixed by the `fix` command.
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