@highstate/git 0.9.33 → 0.9.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-DGBBWS7F.js → chunk-DSKRYOYU.js} +2 -2
- package/dist/{chunk-DGBBWS7F.js.map → chunk-DSKRYOYU.js.map} +1 -1
- package/dist/highstate.manifest.json +2 -2
- package/dist/index.js +1 -1
- package/dist/remote-repository/index.js +1 -1
- package/package.json +7 -7
- package/src/shared/files.ts +1 -1
@@ -290,5 +290,5 @@ var MaterializedRepository = class _MaterializedRepository {
|
|
290
290
|
};
|
291
291
|
|
292
292
|
export { MaterializedRepository, __callDispose, __using };
|
293
|
-
//# sourceMappingURL=chunk-
|
294
|
-
//# sourceMappingURL=chunk-
|
293
|
+
//# sourceMappingURL=chunk-DSKRYOYU.js.map
|
294
|
+
//# sourceMappingURL=chunk-DSKRYOYU.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/shared/files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CO,IAAM,sBAAA,GAAN,MAAM,uBAAA,CAAkD;AAAA,EAK7D,WAAA,CACW,QACQ,MAAA,EACjB;AAFS,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACQ,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAChB;AAAA,EAPK,KAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EAOR,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AAAA,EAEA,IAAI,GAAA,GAAiB;AACnB,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACd;AAAA,EAEA,IAAI,MAAA,GAA6B;AAC/B,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EACd;AAAA,EAEA,IAAI,YAAA,GAAiC;AACnC,IAAA,OAAO,KAAK,MAAA,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,MAAM,KAAA;AAAA,IACR;AAEA,IAAA,OAAO,gBAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAa,MAAA,CAAO,IAAA,EAAc,IAAA,EAAgD;AAChF,IAAA,MAAM,MAAA,GAAwB;AAAA,MAC5B,IAAA,EAAM;AAAA,QACJ,IAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,OAAA,EAAS;AAAA,QACP,IAAA,EAAM,UAAA;AAAA,QACN,OAAO,EAAC;AAAA,QACR,SAAS;AAAC;AACZ,KACF;AAEA,IAAA,MAAM,gBAAA,GAAmB,IAAI,uBAAA,CAAuB,MAAM,CAAA;AAE1D,IAAA,IAAI;AACF,MAAA,MAAM,iBAAiB,KAAA,EAAM;AAAA,IAC/B,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,gBAAA,CAAiB,MAAA,CAAO,YAAY,CAAA,EAAE;AAC5C,MAAA,MAAM,KAAA;AAAA,IACR;AAEA,IAAA,OAAO,gBAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,aAAa,IAAA,CACX,UAAA,EACA,MAAA,EACiC;AACjC,IAAA,MAAM,gBAAA,GAAmB,IAAI,uBAAA,CAAuB,UAAA,EAAY,MAAM,CAAA;AAEtE,IAAA,IAAI;AACF,MAAA,MAAM,iBAAiB,KAAA,EAAM;AAAA,IAC/B,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,gBAAA,CAAiB,MAAA,CAAO,YAAY,CAAA,EAAE;AAC5C,MAAA,MAAM,KAAA;AAAA,IACR;AAEA,IAAA,OAAO,gBAAA;AAAA,EACT;AACF","file":"chunk-DGBBWS7F.js","sourcesContent":["import type { CommonObjectMeta } from \"@highstate/contract\"\nimport type { common } from \"@highstate/library\"\nimport { glob, readFile, stat } from \"node:fs/promises\"\nimport { dirname, extname, join } from \"node:path\"\nimport {\n type FolderPackOptions,\n getNameByEndpoint,\n type InputL7Endpoint,\n l7EndpointToString,\n MaterializedFolder,\n parseL7Endpoint,\n} from \"@highstate/common\"\nimport { type SimpleGit, simpleGit } from \"simple-git\"\n\nexport type RepositoryPackOptions = FolderPackOptions & {\n /**\n * Whether the .git directory should be included in the packed artifact.\n *\n * If true, all the history will be included and all git operations will be available,\n * but the artifact will be larger and will not be reproducible since some files inside .git\n * contain timestamps.\n *\n * If false, the .git directory will not be included in the packed artifact,\n * making the artifact smaller and reproducible, but git operations will be\n * executed on empty repository with no history.\n *\n * By default, this is false.\n */\n includeGit?: boolean\n\n /**\n * Whether to include ignored files specified in .gitignore in the packed artifact.\n *\n * By default, this is false.\n */\n includeIgnored?: boolean\n}\n\n/**\n * The `MaterializedRepository` class represents a git repository entity that has been materialized\n * to a local filesystem path.\n *\n * It embeds MaterializedFolder and adds git-specific operations like cloning, initializing,\n * and checking out branches.\n */\nexport class MaterializedRepository implements AsyncDisposable {\n private _path!: string\n private _folder!: MaterializedFolder\n private _git!: SimpleGit\n\n constructor(\n readonly entity: common.Folder,\n private readonly parent?: MaterializedRepository | MaterializedFolder,\n ) {}\n\n get path(): string {\n return this._path\n }\n\n get git(): SimpleGit {\n return this._git\n }\n\n get folder(): MaterializedFolder {\n return this._folder\n }\n\n get artifactMeta(): CommonObjectMeta {\n return this.folder.artifactMeta\n }\n\n /**\n * Determines if a remote path should be handled as a git repository.\n * Returns true if path ends with .git or has no extension.\n */\n private _shouldCloneAsGitRepo(remotePath: string): boolean {\n return remotePath.endsWith(\".git\") || !extname(remotePath)\n }\n\n private getParent(): MaterializedFolder | undefined {\n if (this.parent instanceof MaterializedRepository) {\n return this.parent.folder\n }\n\n return this.parent\n }\n\n /**\n * Opens the repository by handling different content types and git-specific operations.\n */\n private async _open(): Promise<void> {\n const folderContent = this.entity.content\n\n switch (folderContent.type) {\n case \"embedded\": {\n // for embedded content, use MaterializedFolder to handle the files\n this._folder = await MaterializedFolder.open(this.entity, this.getParent())\n this._path = this._folder.path\n\n // initialize git repository if it's not already one\n await this._initializeGitIfNeeded()\n break\n }\n case \"local\": {\n // for local content, first materialize the folder then handle git operations\n this._folder = await MaterializedFolder.open(this.entity, this.getParent())\n this._path = this._folder.path\n\n // check if it's already a git repository, if not initialize it\n await this._initializeGitIfNeeded()\n break\n }\n case \"remote\": {\n const url = l7EndpointToString(folderContent.endpoint)\n\n // check if remote path should be cloned as git repo\n if (this._shouldCloneAsGitRepo(url)) {\n // create empty folder and materialize it for cloning\n this._folder = await MaterializedFolder.create(\n this.entity.meta.name,\n undefined,\n this.getParent(),\n )\n\n this.artifactMeta.description = `Cloned from \"${url}\".`\n\n this._path = this._folder.path\n await this._cloneRepository()\n } else {\n // use MaterializedFolder for non-git remote content\n this._folder = await MaterializedFolder.open(this.entity, this.getParent())\n this._path = this._folder.path\n await this._initializeGitIfNeeded()\n }\n break\n }\n case \"artifact\": {\n // for artifact content, use MaterializedFolder to extract and then handle git operations\n this._folder = await MaterializedFolder.open(this.entity, this.getParent())\n this._path = this._folder.path\n\n // initialize git repository if needed\n await this._initializeGitIfNeeded()\n break\n }\n }\n\n // set artifact metadata\n this.artifactMeta.title = \"Git Repository\"\n this.artifactMeta.icon = \"simple-icons:git\"\n this.artifactMeta.iconColor = \"#f1502f\"\n\n // initialize git instance\n this._git = simpleGit(this._path)\n\n // set up user\n await this.git.addConfig(\"user.name\", \"Highstate\")\n await this.git.addConfig(\"user.email\", \"highstate@highstate.io\")\n }\n\n /**\n * Clones a remote git repository.\n */\n private async _cloneRepository(): Promise<void> {\n const folderContent = this.entity.content\n if (folderContent.type !== \"remote\") {\n throw new Error(\"Expected remote folder content for cloning\")\n }\n\n const url = l7EndpointToString(folderContent.endpoint)\n\n try {\n const git = simpleGit()\n await git.clone(url, this._path)\n } catch (error) {\n throw new Error(\n `Failed to clone repository: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n /**\n * Initializes a git repository if the directory is not already a git repository.\n */\n private async _initializeGitIfNeeded(): Promise<void> {\n const gitDir = join(this._folder.path, \".git\")\n\n try {\n await stat(gitDir)\n // .git directory exists, assume it's already a git repository\n return\n } catch {\n // .git directory doesn't exist, initialize the repository\n }\n\n try {\n const git = simpleGit(this._folder.path)\n await git.init()\n } catch (error) {\n throw new Error(\n `Failed to initialize git repository: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n async [Symbol.asyncDispose](): Promise<void> {\n try {\n // dispose the embedded folder\n await this._folder[Symbol.asyncDispose]()\n } catch (error) {\n // ignore errors during cleanup\n console.warn(\"failed to clean up materialized repository:\", error)\n }\n }\n\n /**\n * Packs the materialized repository into an artifact and returns the repository entity with artifact content.\n */\n async pack({\n include,\n exclude,\n includeGit,\n includeIgnored,\n }: RepositoryPackOptions = {}): Promise<common.Folder> {\n const excludePatterns = [...(exclude ?? []), ...(includeGit ? [] : [\".git\"])]\n\n if (!includeIgnored) {\n const gitIgnorePatterns = await this.getGitIgnorePatterns()\n excludePatterns.push(...gitIgnorePatterns)\n }\n\n return await this._folder.pack({\n include,\n exclude: excludePatterns,\n })\n }\n\n private async getGitIgnorePatterns(): Promise<string[]> {\n const result: string[] = []\n const gitIgnoreFiles = glob(\".gitignore\", { cwd: this._folder.path })\n\n for await (const file of gitIgnoreFiles) {\n const filePath = join(this._folder.path, file)\n try {\n const relativePrefix = dirname(file)\n\n const content = await readFile(filePath, \"utf-8\")\n const patterns = content\n .split(\"\\n\")\n .map(line => line.trim())\n // remove empty lines and comments\n .filter(line => line && !line.startsWith(\"#\"))\n // append relative prefix to patterns\n .map(pattern => {\n if (relativePrefix === \".\") {\n return pattern\n }\n\n return join(relativePrefix, pattern)\n })\n\n result.push(...patterns)\n } catch (error) {\n console.warn(`Failed to read .gitignore file at ${filePath}:`, error)\n }\n }\n\n return result\n }\n\n /**\n * Clones a remote git repository into a new materialized repository.\n *\n * @param endpoint The L7 endpoint of the remote repository to clone\n * @param name The optional name for the new repository\n * @param mode Optional directory mode (permissions)\n */\n static async clone(\n endpoint: InputL7Endpoint,\n name?: string,\n mode?: number,\n ): Promise<MaterializedRepository> {\n const parsedEndpoint = parseL7Endpoint(endpoint)\n\n const entity: common.Folder = {\n meta: {\n name: name ?? getNameByEndpoint(parsedEndpoint),\n mode,\n },\n content: {\n type: \"remote\",\n endpoint: parsedEndpoint,\n },\n }\n\n const materializedRepo = new MaterializedRepository(entity)\n\n try {\n await materializedRepo._open()\n } catch (error) {\n await materializedRepo[Symbol.asyncDispose]()\n throw error\n }\n\n return materializedRepo\n }\n\n /**\n * Creates an empty materialized repository with the given name.\n *\n * @param name The name of the repository to create\n * @param mode Optional directory mode (permissions)\n * @returns A new MaterializedRepository instance representing an empty repository\n */\n static async create(name: string, mode?: number): Promise<MaterializedRepository> {\n const entity: common.Folder = {\n meta: {\n name,\n mode,\n },\n content: {\n type: \"embedded\",\n files: [],\n folders: [],\n },\n }\n\n const materializedRepo = new MaterializedRepository(entity)\n\n try {\n await materializedRepo._open()\n } catch (error) {\n await materializedRepo[Symbol.asyncDispose]()\n throw error\n }\n\n return materializedRepo\n }\n\n /**\n * Opens a git repository entity and materializes it to the filesystem.\n *\n * @param repository The repository entity to materialize\n * @returns A new MaterializedRepository instance\n */\n static async open(\n repository: common.Folder,\n parent?: MaterializedRepository | MaterializedFolder,\n ): Promise<MaterializedRepository> {\n const materializedRepo = new MaterializedRepository(repository, parent)\n\n try {\n await materializedRepo._open()\n } catch (error) {\n await materializedRepo[Symbol.asyncDispose]()\n throw error\n }\n\n return materializedRepo\n }\n}\n"]}
|
1
|
+
{"version":3,"sources":["../src/shared/files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CO,IAAM,sBAAA,GAAN,MAAM,uBAAA,CAAkD;AAAA,EAK7D,WAAA,CACW,QACQ,MAAA,EACjB;AAFS,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACQ,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAChB;AAAA,EAPK,KAAA;AAAA,EACA,OAAA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gBAAA,CAAiB,MAAA,CAAO,YAAY,CAAA,EAAE;AAC5C,MAAA,MAAM,KAAA;AAAA,IACR;AAEA,IAAA,OAAO,gBAAA;AAAA,EACT;AACF","file":"chunk-DSKRYOYU.js","sourcesContent":["import type { CommonObjectMeta } from \"@highstate/contract\"\nimport type { common } from \"@highstate/library\"\nimport { glob, readFile, stat } from \"node:fs/promises\"\nimport { dirname, extname, join } from \"node:path\"\nimport {\n type FolderPackOptions,\n getNameByEndpoint,\n type InputL7Endpoint,\n l7EndpointToString,\n MaterializedFolder,\n parseL7Endpoint,\n} from \"@highstate/common\"\nimport { type SimpleGit, simpleGit } from \"simple-git\"\n\nexport type RepositoryPackOptions = FolderPackOptions & {\n /**\n * Whether the .git directory should be included in the packed artifact.\n *\n * If true, all the history will be included and all git operations will be available,\n * but the artifact will be larger and will not be reproducible since some files inside .git\n * contain timestamps.\n *\n * If false, the .git directory will not be included in the packed artifact,\n * making the artifact smaller and reproducible, but git operations will be\n * executed on empty repository with no history.\n *\n * By default, this is false.\n */\n includeGit?: boolean\n\n /**\n * Whether to include ignored files specified in .gitignore in the packed artifact.\n *\n * By default, this is false.\n */\n includeIgnored?: boolean\n}\n\n/**\n * The `MaterializedRepository` class represents a git repository entity that has been materialized\n * to a local filesystem path.\n *\n * It embeds MaterializedFolder and adds git-specific operations like cloning, initializing,\n * and checking out branches.\n */\nexport class MaterializedRepository implements AsyncDisposable {\n private _path!: string\n private _folder!: MaterializedFolder\n private _git!: SimpleGit\n\n constructor(\n readonly entity: common.Folder,\n private readonly parent?: MaterializedRepository | MaterializedFolder,\n ) {}\n\n get path(): string {\n return this._path\n }\n\n get git(): SimpleGit {\n return this._git\n }\n\n get folder(): MaterializedFolder {\n return this._folder\n }\n\n get artifactMeta(): CommonObjectMeta {\n return this.folder.artifactMeta\n }\n\n /**\n * Determines if a remote path should be handled as a git repository.\n * Returns true if path ends with .git or has no extension.\n */\n private _shouldCloneAsGitRepo(remotePath: string): boolean {\n return remotePath.endsWith(\".git\") || !extname(remotePath)\n }\n\n private getParent(): MaterializedFolder | undefined {\n if (this.parent instanceof MaterializedRepository) {\n return this.parent.folder\n }\n\n return this.parent\n }\n\n /**\n * Opens the repository by handling different content types and git-specific operations.\n */\n private async _open(): Promise<void> {\n const folderContent = this.entity.content\n\n switch (folderContent.type) {\n case \"embedded\": {\n // for embedded content, use MaterializedFolder to handle the files\n this._folder = await MaterializedFolder.open(this.entity, this.getParent())\n this._path = this._folder.path\n\n // initialize git repository if it's not already one\n await this._initializeGitIfNeeded()\n break\n }\n case \"local\": {\n // for local content, first materialize the folder then handle git operations\n this._folder = await MaterializedFolder.open(this.entity, this.getParent())\n this._path = this._folder.path\n\n // check if it's already a git repository, if not initialize it\n await this._initializeGitIfNeeded()\n break\n }\n case \"remote\": {\n const url = l7EndpointToString(folderContent.endpoint)\n\n // check if remote path should be cloned as git repo\n if (this._shouldCloneAsGitRepo(url)) {\n // create empty folder and materialize it for cloning\n this._folder = await MaterializedFolder.create(\n this.entity.meta.name,\n undefined,\n this.getParent(),\n )\n\n this.artifactMeta.description = `Cloned from \"${url}\".`\n\n this._path = this._folder.path\n await this._cloneRepository()\n } else {\n // use MaterializedFolder for non-git remote content\n this._folder = await MaterializedFolder.open(this.entity, this.getParent())\n this._path = this._folder.path\n await this._initializeGitIfNeeded()\n }\n break\n }\n case \"artifact\": {\n // for artifact content, use MaterializedFolder to extract and then handle git operations\n this._folder = await MaterializedFolder.open(this.entity, this.getParent())\n this._path = this._folder.path\n\n // initialize git repository if needed\n await this._initializeGitIfNeeded()\n break\n }\n }\n\n // set artifact metadata\n this.artifactMeta.title = \"Git Repository\"\n this.artifactMeta.icon = \"simple-icons:git\"\n this.artifactMeta.iconColor = \"#f1502f\"\n\n // initialize git instance\n this._git = simpleGit(this._path)\n\n // set up user\n await this.git.addConfig(\"user.name\", \"Highstate\")\n await this.git.addConfig(\"user.email\", \"highstate@highstate.io\")\n }\n\n /**\n * Clones a remote git repository.\n */\n private async _cloneRepository(): Promise<void> {\n const folderContent = this.entity.content\n if (folderContent.type !== \"remote\") {\n throw new Error(\"Expected remote folder content for cloning\")\n }\n\n const url = l7EndpointToString(folderContent.endpoint)\n\n try {\n const git = simpleGit()\n await git.clone(url, this._path)\n } catch (error) {\n throw new Error(\n `Failed to clone repository: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n /**\n * Initializes a git repository if the directory is not already a git repository.\n */\n private async _initializeGitIfNeeded(): Promise<void> {\n const gitDir = join(this._folder.path, \".git\")\n\n try {\n await stat(gitDir)\n // .git directory exists, assume it's already a git repository\n return\n } catch {\n // .git directory doesn't exist, initialize the repository\n }\n\n try {\n const git = simpleGit(this._folder.path)\n await git.init()\n } catch (error) {\n throw new Error(\n `Failed to initialize git repository: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n async [Symbol.asyncDispose](): Promise<void> {\n try {\n // dispose the embedded folder\n await this._folder[Symbol.asyncDispose]()\n } catch (error) {\n // ignore errors during cleanup\n console.warn(\"failed to clean up materialized repository:\", error)\n }\n }\n\n /**\n * Packs the materialized repository into an artifact and returns the repository entity with artifact content.\n */\n async pack({\n include,\n exclude,\n includeGit,\n includeIgnored,\n }: RepositoryPackOptions = {}): Promise<common.ArtifactFolder> {\n const excludePatterns = [...(exclude ?? []), ...(includeGit ? [] : [\".git\"])]\n\n if (!includeIgnored) {\n const gitIgnorePatterns = await this.getGitIgnorePatterns()\n excludePatterns.push(...gitIgnorePatterns)\n }\n\n return await this._folder.pack({\n include,\n exclude: excludePatterns,\n })\n }\n\n private async getGitIgnorePatterns(): Promise<string[]> {\n const result: string[] = []\n const gitIgnoreFiles = glob(\".gitignore\", { cwd: this._folder.path })\n\n for await (const file of gitIgnoreFiles) {\n const filePath = join(this._folder.path, file)\n try {\n const relativePrefix = dirname(file)\n\n const content = await readFile(filePath, \"utf-8\")\n const patterns = content\n .split(\"\\n\")\n .map(line => line.trim())\n // remove empty lines and comments\n .filter(line => line && !line.startsWith(\"#\"))\n // append relative prefix to patterns\n .map(pattern => {\n if (relativePrefix === \".\") {\n return pattern\n }\n\n return join(relativePrefix, pattern)\n })\n\n result.push(...patterns)\n } catch (error) {\n console.warn(`Failed to read .gitignore file at ${filePath}:`, error)\n }\n }\n\n return result\n }\n\n /**\n * Clones a remote git repository into a new materialized repository.\n *\n * @param endpoint The L7 endpoint of the remote repository to clone\n * @param name The optional name for the new repository\n * @param mode Optional directory mode (permissions)\n */\n static async clone(\n endpoint: InputL7Endpoint,\n name?: string,\n mode?: number,\n ): Promise<MaterializedRepository> {\n const parsedEndpoint = parseL7Endpoint(endpoint)\n\n const entity: common.Folder = {\n meta: {\n name: name ?? getNameByEndpoint(parsedEndpoint),\n mode,\n },\n content: {\n type: \"remote\",\n endpoint: parsedEndpoint,\n },\n }\n\n const materializedRepo = new MaterializedRepository(entity)\n\n try {\n await materializedRepo._open()\n } catch (error) {\n await materializedRepo[Symbol.asyncDispose]()\n throw error\n }\n\n return materializedRepo\n }\n\n /**\n * Creates an empty materialized repository with the given name.\n *\n * @param name The name of the repository to create\n * @param mode Optional directory mode (permissions)\n * @returns A new MaterializedRepository instance representing an empty repository\n */\n static async create(name: string, mode?: number): Promise<MaterializedRepository> {\n const entity: common.Folder = {\n meta: {\n name,\n mode,\n },\n content: {\n type: \"embedded\",\n files: [],\n folders: [],\n },\n }\n\n const materializedRepo = new MaterializedRepository(entity)\n\n try {\n await materializedRepo._open()\n } catch (error) {\n await materializedRepo[Symbol.asyncDispose]()\n throw error\n }\n\n return materializedRepo\n }\n\n /**\n * Opens a git repository entity and materializes it to the filesystem.\n *\n * @param repository The repository entity to materialize\n * @returns A new MaterializedRepository instance\n */\n static async open(\n repository: common.Folder,\n parent?: MaterializedRepository | MaterializedFolder,\n ): Promise<MaterializedRepository> {\n const materializedRepo = new MaterializedRepository(repository, parent)\n\n try {\n await materializedRepo._open()\n } catch (error) {\n await materializedRepo[Symbol.asyncDispose]()\n throw error\n }\n\n return materializedRepo\n }\n}\n"]}
|
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { __using, MaterializedRepository, __callDispose } from '../chunk-
|
1
|
+
import { __using, MaterializedRepository, __callDispose } from '../chunk-DSKRYOYU.js';
|
2
2
|
import { git } from '@highstate/library';
|
3
3
|
import { forUnit, toPromise } from '@highstate/pulumi';
|
4
4
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@highstate/git",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.35",
|
4
4
|
"type": "module",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -23,18 +23,18 @@
|
|
23
23
|
"biome:check": "biome check --error-on-warnings"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@highstate/common": "^0.9.
|
27
|
-
"@highstate/contract": "^0.9.
|
28
|
-
"@highstate/library": "^0.9.
|
29
|
-
"@highstate/pulumi": "^0.9.
|
26
|
+
"@highstate/common": "^0.9.35",
|
27
|
+
"@highstate/contract": "^0.9.35",
|
28
|
+
"@highstate/library": "^0.9.35",
|
29
|
+
"@highstate/pulumi": "^0.9.35",
|
30
30
|
"remeda": "^2.21.0",
|
31
31
|
"simple-git": "^3.27.0",
|
32
32
|
"tar": "^7.4.3"
|
33
33
|
},
|
34
34
|
"devDependencies": {
|
35
35
|
"@biomejs/biome": "2.2.0",
|
36
|
-
"@highstate/cli": "^0.9.
|
36
|
+
"@highstate/cli": "^0.9.35",
|
37
37
|
"@typescript/native-preview": "^7.0.0-dev.20250920.1"
|
38
38
|
},
|
39
|
-
"gitHead": "
|
39
|
+
"gitHead": "52d9ed8e0d51156b2476b31adc49cc796bd4b508"
|
40
40
|
}
|
package/src/shared/files.ts
CHANGED
@@ -221,7 +221,7 @@ export class MaterializedRepository implements AsyncDisposable {
|
|
221
221
|
exclude,
|
222
222
|
includeGit,
|
223
223
|
includeIgnored,
|
224
|
-
}: RepositoryPackOptions = {}): Promise<common.
|
224
|
+
}: RepositoryPackOptions = {}): Promise<common.ArtifactFolder> {
|
225
225
|
const excludePatterns = [...(exclude ?? []), ...(includeGit ? [] : [".git"])]
|
226
226
|
|
227
227
|
if (!includeIgnored) {
|