Unit Utils.Adopt

Description

Unit which contains functions to convert an existing project to the workspace layout. The project is first analyzed into a plan, that can be shown without changing anything, and then the plan is applied.

Supported layouts: - an app with a .lpi and .lpr at the root (created by pasc new, with a src folder, or a plain lazarus app with its units at the root): it is moved to apps/name, while boss files stay at the root as the workspace manifest; - a repository with several projects or packages (or a .lpg project group): it is adopted in place, pasc.json lists the existing folders as members and nothing is moved. A boss library (sources consumed by other repositories through its "mainsrc") is refused, since it should stay in its own repository.

Overview

Classes, Interfaces, Objects and Records

Name Description
Record TAdoptMove A file or folder moved by the adoption, relative to the root.
Record TAdoptReference A required package without a DefaultFilename in a member project.
Record TAdoptPlan Result of the analysis of a project, applied by ApplyAdoption.

Functions and Procedures

function AnalyzeAdoption(const ARoot: string; const AForce: Boolean): TAdoptPlan;
function ApplyAdoption(const APlan: TAdoptPlan): TArray<string>;
function RebasePath(const AEntry, AOldDir, ANewDir: string; const AMovedPaths: TArray<string>): string;

Types

TAdoptKind = (...);

Description

Functions and Procedures

function AnalyzeAdoption(const ARoot: string; const AForce: Boolean): TAdoptPlan;

Analyzes a project and returns the plan to convert it to a workspace. Nothing is changed.

Parameters
ARoot
Project root folder.
AForce
Accepts a git working tree with uncommitted changes.
function ApplyAdoption(const APlan: TAdoptPlan): TArray<string>;

Applies a plan returned by AnalyzeAdoption. Returns the description of each change. Tracked files are moved with git mv to keep their history.

Parameters
APlan
Plan to apply, of kind akApp, akPlainApp or akMultiProject.
function RebasePath(const AEntry, AOldDir, ANewDir: string; const AMovedPaths: TArray<string>): string;

Returns the given relative path, of an entry of a project file that was at AOldDir and is now at ANewDir, so that it still points to the same place. Paths that point inside one of the moved folders or files are kept, as they moved together. Lazarus macros are kept.

Parameters
AEntry
Path as written in the project file.
AOldDir
Previous folder of the project file.
ANewDir
Current folder of the project file.
AMovedPaths
Complete previous paths of everything that was moved.

Types

TAdoptKind = (...);

Layout detected in the project to adopt.

Values
  • akRefused: The project cannot be adopted, see the plan Reason.
  • akApp: An app with a src folder, as created by pasc new.
  • akPlainApp: A lazarus app with its units at the root.
  • akMultiProject: Several projects or packages, adopted in place.

Generated by PasDoc 1.0.4.