Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

nx

Package Overview
Dependencies
Maintainers
8
Versions
2573
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nx - npm Package Compare versions

Comparing version
23.0.0-beta.18
to
23.0.0-beta.19
+19
-0
dist/src/command-line/migrate/prompt-files.d.ts

@@ -5,2 +5,21 @@ import { MigrationsJson } from '../../config/misc-interfaces';

export declare function validateMigrationEntries(packageName: string, packageVersion: string, migrations: MigrationsJson): void;
/**
* Thrown when the markdown prompt file referenced by a migration cannot be
* resolved.
*/
export declare class PromptResolutionError extends Error {
readonly promptPath: string;
readonly migrationsDir: string;
constructor(promptPath: string, migrationsDir: string, options?: {
cause?: unknown;
});
}
/**
* Resolves a migration prompt file path to an absolute path. Prompt paths are
* plain markdown files referenced relative to the directory containing the
* `migrations.json` - unlike schemas, they are not resolved through package
* exports or `require.resolve`. The path must stay within the migrations
* directory and point at an existing file.
*/
export declare function resolvePrompt(promptPath: string, migrationsDir: string): string;
export declare function extractPromptFilesFromTarball(packageName: string, packageVersion: string, migrations: MigrationsJson, migrationsFilePath: string, fullTarballPath: string, destDir: string): Promise<Record<string, string> | undefined>;

@@ -7,0 +26,0 @@ export declare function readPromptFilesFromInstall(packageName: string, packageVersion: string, migrations: MigrationsJson, migrationsFilePath: string): Promise<Record<string, string> | undefined>;

+38
-4
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AI_MIGRATIONS_DIR = void 0;
exports.PromptResolutionError = exports.AI_MIGRATIONS_DIR = void 0;
exports.promptContentKey = promptContentKey;
exports.validateMigrationEntries = validateMigrationEntries;
exports.resolvePrompt = resolvePrompt;
exports.extractPromptFilesFromTarball = extractPromptFilesFromTarball;

@@ -46,11 +47,44 @@ exports.readPromptFilesFromInstall = readPromptFilesFromInstall;

}
function assertPromptPathWithinMigrationsDir(migrationsDir, promptRelPath, packageName, packageVersion) {
function isPromptPathWithinMigrationsDir(migrationsDir, promptRelPath) {
const rel = (0, path_1.relative)(migrationsDir, (0, path_1.join)(migrationsDir, promptRelPath));
if ((0, path_1.isAbsolute)(promptRelPath) ||
return !((0, path_1.isAbsolute)(promptRelPath) ||
rel === '..' ||
rel.startsWith(`..${path_1.sep}`) ||
rel.startsWith(`..${path_1.posix.sep}`)) {
rel.startsWith(`..${path_1.posix.sep}`));
}
function assertPromptPathWithinMigrationsDir(migrationsDir, promptRelPath, packageName, packageVersion) {
if (!isPromptPathWithinMigrationsDir(migrationsDir, promptRelPath)) {
throw new Error(`Invalid prompt path "${promptRelPath}" in package "${packageName}@${packageVersion}": prompt paths must be relative and resolve within the package's migrations directory.`);
}
}
/**
* Thrown when the markdown prompt file referenced by a migration cannot be
* resolved.
*/
class PromptResolutionError extends Error {
constructor(promptPath, migrationsDir, options) {
super(`Could not resolve prompt "${promptPath}" from "${migrationsDir}".`, options);
this.promptPath = promptPath;
this.migrationsDir = migrationsDir;
this.name = 'PromptResolutionError';
}
}
exports.PromptResolutionError = PromptResolutionError;
/**
* Resolves a migration prompt file path to an absolute path. Prompt paths are
* plain markdown files referenced relative to the directory containing the
* `migrations.json` - unlike schemas, they are not resolved through package
* exports or `require.resolve`. The path must stay within the migrations
* directory and point at an existing file.
*/
function resolvePrompt(promptPath, migrationsDir) {
if (!isPromptPathWithinMigrationsDir(migrationsDir, promptPath)) {
throw new PromptResolutionError(promptPath, migrationsDir);
}
const resolvedPath = (0, path_1.join)(migrationsDir, promptPath);
if (!(0, fs_1.existsSync)(resolvedPath)) {
throw new PromptResolutionError(promptPath, migrationsDir);
}
return resolvedPath;
}
function extractPromptFilesFromTarball(packageName, packageVersion, migrations, migrationsFilePath, fullTarballPath, destDir) {

@@ -57,0 +91,0 @@ const migrationsDir = (0, path_1.dirname)(migrationsFilePath);

import type { ProjectConfiguration } from './workspace-json-project-json';
/**
* Thrown when the schema file of an executor or generator cannot be resolved.
*/
export declare class SchemaResolutionError extends Error {
readonly schemaPath: string;
readonly directory: string;
constructor(schemaPath: string, directory: string, options?: {
cause?: unknown;
});
}
/**
* Thrown when the implementation module of an executor or generator cannot be
* resolved.
*/
export declare class ImplementationResolutionError extends Error {
readonly implementationModulePath: string;
readonly directory: string;
constructor(implementationModulePath: string, directory: string, options?: {
cause?: unknown;
});
}
/**
* This function is used to get the implementation factory of an executor or generator.

@@ -4,0 +25,0 @@ * @param implementation path to the implementation

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImplementationResolutionError = exports.SchemaResolutionError = void 0;
exports.getImplementationFactory = getImplementationFactory;

@@ -12,4 +13,33 @@ exports.resolveImplementation = resolveImplementation;

const typescript_1 = require("../plugins/js/utils/typescript");
const find_project_for_path_1 = require("../project-graph/utils/find-project-for-path");
const fileutils_1 = require("../utils/fileutils");
const package_json_1 = require("../utils/package-json");
const path_2 = require("../utils/path");
const workspace_root_1 = require("../utils/workspace-root");
/**
* Thrown when the schema file of an executor or generator cannot be resolved.
*/
class SchemaResolutionError extends Error {
constructor(schemaPath, directory, options) {
super(`Could not resolve schema "${schemaPath}" from "${directory}".`, options);
this.schemaPath = schemaPath;
this.directory = directory;
this.name = 'SchemaResolutionError';
}
}
exports.SchemaResolutionError = SchemaResolutionError;
/**
* Thrown when the implementation module of an executor or generator cannot be
* resolved.
*/
class ImplementationResolutionError extends Error {
constructor(implementationModulePath, directory, options) {
super(`Could not resolve "${implementationModulePath}" from "${directory}".`, options);
this.implementationModulePath = implementationModulePath;
this.directory = directory;
this.name = 'ImplementationResolutionError';
}
}
exports.ImplementationResolutionError = ImplementationResolutionError;
/**
* This function is used to get the implementation factory of an executor or generator.

@@ -68,3 +98,3 @@ * @param implementation path to the implementation

}
throw new Error(`Could not resolve "${implementationModulePath}" from "${directory}".`);
throw new ImplementationResolutionError(implementationModulePath, directory);
}

@@ -85,20 +115,59 @@ function resolveSchema(schemaPath, directory, packageName, projects) {

}
return require.resolve(schemaPath, {
paths: [directory],
});
try {
return require.resolve(schemaPath, {
paths: [directory],
});
}
catch (e) {
throw new SchemaResolutionError(schemaPath, directory, { cause: e });
}
}
let packageToProjectMap;
let projectRootMappings;
function getProjectForDirectory(directory, projects) {
projectRootMappings ??=
(0, find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations)(projects);
const projectName = (0, find_project_for_path_1.findProjectForPath)((0, path_1.relative)(workspace_root_1.workspaceRoot, directory), projectRootMappings);
return projectName ? projects[projectName] : null;
}
/**
* Reads the JS package metadata (package name and exports) for a project
* directly from its `package.json`. Used as a fallback when a project's graph
* metadata doesn't include the JS metadata.
*/
function readJsPackageMetadata(project) {
const packageJsonPath = (0, path_1.join)(workspace_root_1.workspaceRoot, project.root, 'package.json');
if (!(0, fs_1.existsSync)(packageJsonPath)) {
return null;
}
try {
const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
return (0, package_json_1.getMetadataFromPackageJson)(packageJson, false).js;
}
catch {
return null;
}
}
let packageMetadata;
function tryResolveFromSource(path, directory, packageName, projects) {
packageToProjectMap ??=
(0, packages_1.getWorkspacePackagesMetadata)(projects).packageToProjectMap;
const localProject = packageToProjectMap[packageName];
packageMetadata ??= (0, packages_1.getWorkspacePackagesMetadata)(projects);
let localProject = packageMetadata.packageToProjectMap[packageName];
// The `packageName` might be a path to the collection rather than an actual
// package name (e.g. when a generator/executor collection is referenced by
// path). In that case, `directory` points inside the local project, so we
// find the project that contains it.
localProject ??= getProjectForDirectory(directory, projects);
if (!localProject) {
// it doesn't match any of the package names from the local projects
return null;
}
const js = localProject.metadata?.js ??
readJsPackageMetadata(localProject);
if (!js) {
return null;
}
const name = js.packageName;
const exports = js.packageExports;
try {
const fromExports = (0, resolve_exports_1.resolve)({
name: localProject.metadata.js.packageName,
exports: localProject.metadata.js.packageExports,
}, path, { conditions: (0, typescript_1.getRootTsConfigResolveExportsConditions)() });
const fromExports = (0, resolve_exports_1.resolve)({ name, exports }, path, {
conditions: (0, typescript_1.getRootTsConfigResolveExportsConditions)(),
});
if (fromExports && fromExports.length) {

@@ -105,0 +174,0 @@ for (const exportPath of fromExports) {

@@ -38,1 +38,3 @@ /**

export { emitPluginWorkerLog } from './project-graph/plugins/isolation/worker-streaming';
export { resolveImplementation, resolveSchema, ImplementationResolutionError, SchemaResolutionError, } from './config/schema-utils';
export { resolvePrompt, PromptResolutionError, } from './command-line/migrate/prompt-files';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.handleImport = exports.signalToCode = exports.globalSpinner = exports.readYamlFile = exports.isUsingPrettierInTree = exports.isCI = exports.interpolate = exports.requireWithTsconfigFallback = exports.forceRegisterEsmLoader = exports.loadTsFile = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappings = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.installPackageToTmpAsync = exports.installPackageToTmp = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.getIgnoreObjectForTree = exports.normalizeTargetDefaultsAgainstRootMaps = exports.readTargetDefaultsForTarget = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.parseExecutor = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.handleImport = exports.signalToCode = exports.globalSpinner = exports.readYamlFile = exports.isUsingPrettierInTree = exports.isCI = exports.interpolate = exports.requireWithTsconfigFallback = exports.forceRegisterEsmLoader = exports.loadTsFile = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappings = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.installPackageToTmpAsync = exports.installPackageToTmp = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.getIgnoreObjectForTree = exports.normalizeTargetDefaultsAgainstRootMaps = exports.readTargetDefaultsForTarget = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.parseExecutor = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
const tslib_1 = require("tslib");

@@ -84,1 +84,9 @@ /**

Object.defineProperty(exports, "emitPluginWorkerLog", { enumerable: true, get: function () { return worker_streaming_1.emitPluginWorkerLog; } });
var schema_utils_1 = require("./config/schema-utils");
Object.defineProperty(exports, "resolveImplementation", { enumerable: true, get: function () { return schema_utils_1.resolveImplementation; } });
Object.defineProperty(exports, "resolveSchema", { enumerable: true, get: function () { return schema_utils_1.resolveSchema; } });
Object.defineProperty(exports, "ImplementationResolutionError", { enumerable: true, get: function () { return schema_utils_1.ImplementationResolutionError; } });
Object.defineProperty(exports, "SchemaResolutionError", { enumerable: true, get: function () { return schema_utils_1.SchemaResolutionError; } });
var prompt_files_1 = require("./command-line/migrate/prompt-files");
Object.defineProperty(exports, "resolvePrompt", { enumerable: true, get: function () { return prompt_files_1.resolvePrompt; } });
Object.defineProperty(exports, "PromptResolutionError", { enumerable: true, get: function () { return prompt_files_1.PromptResolutionError; } });
+1
-1

@@ -639,3 +639,3 @@ /**

/** Determines if a given task should be cacheable. */
cache?: boolean
cache: boolean
/** Determines if a given task should be parallelizable. */

@@ -642,0 +642,0 @@ parallelism?: boolean

@@ -11,3 +11,3 @@ "use strict";

for (const project of Object.values(projects)) {
const metadata = 'data' in project ? project.data.metadata : project.metadata;
const metadata = ('data' in project ? project.data.metadata : project.metadata);
if (!metadata?.js) {

@@ -14,0 +14,0 @@ continue;

@@ -208,3 +208,3 @@ "use strict";

outputs: (0, utils_1.getOutputs)(this.projectGraph.nodes, qualifiedTarget, interpolatedOverrides),
cache: project.data.targets[target].cache,
cache: project.data.targets[target].cache ?? false,
parallelism: project.data.targets[target].parallelism ?? true,

@@ -211,0 +211,0 @@ continuous: project.data.targets[target].continuous ?? false,

@@ -15,4 +15,2 @@ import { TasksRunner } from './tasks-runner';

parallel?: number;
cacheableOperations?: string[];
cacheableTargets?: string[];
runtimeCacheInputs?: string[];

@@ -19,0 +17,0 @@ cacheDirectory?: string;

@@ -59,7 +59,3 @@ import { CustomHasher, ExecutorConfig } from '../config/misc-interfaces';

export declare function shouldStreamOutput(task: Task, initiatingProject: string | null): boolean;
export declare function isCacheableTask(task: Task, options: {
cacheableOperations?: string[] | null;
cacheableTargets?: string[] | null;
}): boolean;
export declare function unparse(options: Object): string[];
export declare function createTaskId(project: string, target: string, configuration: string | undefined): string;

@@ -27,3 +27,2 @@ "use strict";

exports.shouldStreamOutput = shouldStreamOutput;
exports.isCacheableTask = isCacheableTask;
exports.unparse = unparse;

@@ -428,11 +427,2 @@ exports.createTaskId = createTaskId;

}
function isCacheableTask(task, options) {
if (task.cache !== undefined) {
return task.cache;
}
const cacheable = options.cacheableOperations || options.cacheableTargets;
return (cacheable &&
cacheable.indexOf(task.target.target) > -1 &&
!longRunningTask(task));
}
function longRunningTask(task) {

@@ -439,0 +429,0 @@ const t = task.target.target;

@@ -95,2 +95,15 @@ import { NxJsonConfiguration } from '../config/nx-json';

export declare function buildTargetFromScript(script: string, scripts: Record<string, string>, packageManagerCommand: PackageManagerCommands): TargetConfiguration;
export type PackageJsonProjectMetadata = {
targetGroups: {
'NPM Scripts'?: Array<string>;
};
description: string;
js: {
packageName: PackageJson['name'];
packageVersion: PackageJson['version'];
packageExports: PackageJson['exports'];
packageMain: PackageJson['main'];
isInPackageManagerWorkspaces: boolean;
};
};
export declare function getMetadataFromPackageJson(packageJson: PackageJson, isInPackageManagerWorkspaces: boolean): ProjectMetadata;

@@ -97,0 +110,0 @@ export declare function getTagsFromPackageJson(packageJson: PackageJson): string[];

@@ -74,6 +74,8 @@ "use strict";

const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
return {
targetGroups: {
...(includedScripts.length ? { 'NPM Scripts': includedScripts } : {}),
},
const metadata = {
targetGroups: includedScripts.length
? {
'NPM Scripts': includedScripts,
}
: {},
description,

@@ -88,2 +90,3 @@ js: {

};
return metadata;
}

@@ -90,0 +93,0 @@ function getTagsFromPackageJson(packageJson) {

{
"name": "nx",
"version": "23.0.0-beta.18",
"version": "23.0.0-beta.19",
"private": false,

@@ -173,12 +173,12 @@ "type": "commonjs",

"optionalDependencies": {
"@nx/nx-darwin-arm64": "23.0.0-beta.18",
"@nx/nx-darwin-x64": "23.0.0-beta.18",
"@nx/nx-freebsd-x64": "23.0.0-beta.18",
"@nx/nx-linux-arm-gnueabihf": "23.0.0-beta.18",
"@nx/nx-linux-arm64-gnu": "23.0.0-beta.18",
"@nx/nx-linux-arm64-musl": "23.0.0-beta.18",
"@nx/nx-linux-x64-gnu": "23.0.0-beta.18",
"@nx/nx-linux-x64-musl": "23.0.0-beta.18",
"@nx/nx-win32-arm64-msvc": "23.0.0-beta.18",
"@nx/nx-win32-x64-msvc": "23.0.0-beta.18"
"@nx/nx-darwin-arm64": "23.0.0-beta.19",
"@nx/nx-darwin-x64": "23.0.0-beta.19",
"@nx/nx-freebsd-x64": "23.0.0-beta.19",
"@nx/nx-linux-arm-gnueabihf": "23.0.0-beta.19",
"@nx/nx-linux-arm64-gnu": "23.0.0-beta.19",
"@nx/nx-linux-arm64-musl": "23.0.0-beta.19",
"@nx/nx-linux-x64-gnu": "23.0.0-beta.19",
"@nx/nx-linux-x64-musl": "23.0.0-beta.19",
"@nx/nx-win32-arm64-msvc": "23.0.0-beta.19",
"@nx/nx-win32-x64-msvc": "23.0.0-beta.19"
},

@@ -185,0 +185,0 @@ "nx-migrations": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display