skuba 11.0.1-fix-nested-repo-usage-20250522060154 → 11.0.1-monorepo-uploadAllFileChanges-20250523041813

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.
@@ -53,17 +53,21 @@ const commitAllChanges = async ({
53
53
  throw new Error(`Could not find Git root from directory: ${dir}`);
54
54
  }
55
55
  await Promise.all(
56
- changedFiles.map(
57
- (file) => file.state === "deleted" ? import_isomorphic_git.default.remove({
56
+ changedFiles.map(async (file) => {
57
+ const relativePath = import_path.default.relative(dir, file.path);
58
+ if (relativePath.startsWith("..")) {
59
+ return;
60
+ }
61
+ return file.state === "deleted" ? import_isomorphic_git.default.remove({
58
62
  fs: import_fs_extra.default,
59
63
  dir: gitRoot,
60
- filepath: import_path.default.relative(gitRoot, import_path.default.join(dir, file.path))
64
+ filepath: file.path
61
65
  }) : import_isomorphic_git.default.add({
62
66
  fs: import_fs_extra.default,
63
67
  dir: gitRoot,
64
- filepath: import_path.default.relative(gitRoot, import_path.default.join(dir, file.path))
65
- })
66
- )
68
+ filepath: file.path
69
+ });
70
+ })
67
71
  );
68
72
  return (0, import_commit.commit)({
69
73
  dir: gitRoot,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/git/commitAllChanges.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\n\nimport { type Identity, commit } from './commit';\nimport { findRoot } from './findRoot';\nimport { type ChangedFile, getChangedFiles } from './getChangedFiles';\n\ninterface CommitAllParameters {\n dir: string;\n message: string;\n author?: Identity;\n committer?: Identity;\n\n /**\n * File changes to exclude from the commit.\n *\n * Defaults to `[]` (no exclusions).\n */\n ignore?: ChangedFile[];\n}\n\n/**\n * Stages all changes and writes a commit to the local Git repository.\n */\nexport const commitAllChanges = async ({\n dir,\n message,\n\n author,\n committer,\n ignore,\n}: CommitAllParameters): Promise<string | undefined> => {\n const changedFiles = await getChangedFiles({ dir, ignore });\n\n if (!changedFiles.length) {\n return;\n }\n\n const gitRoot = await findRoot({ dir });\n\n if (!gitRoot) {\n throw new Error(`Could not find Git root from directory: ${dir}`);\n }\n\n await Promise.all(\n changedFiles.map((file) =>\n file.state === 'deleted'\n ? git.remove({\n fs,\n dir: gitRoot,\n filepath: path.relative(gitRoot, path.join(dir, file.path)),\n })\n : git.add({\n fs,\n dir: gitRoot,\n filepath: path.relative(gitRoot, path.join(dir, file.path)),\n }),\n ),\n );\n\n return commit({\n dir: gitRoot,\n message,\n author,\n committer,\n });\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAEhB,oBAAsC;AACtC,sBAAyB;AACzB,6BAAkD;AAmB3C,MAAM,mBAAmB,OAAO;AAAA,EACrC;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AACF,MAAwD;AACtD,QAAM,eAAe,UAAM,wCAAgB,EAAE,KAAK,OAAO,CAAC;AAE1D,MAAI,CAAC,aAAa,QAAQ;AACxB;AAAA,EACF;AAEA,QAAM,UAAU,UAAM,0BAAS,EAAE,IAAI,CAAC;AAEtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,2CAA2C,GAAG,EAAE;AAAA,EAClE;AAEA,QAAM,QAAQ;AAAA,IACZ,aAAa;AAAA,MAAI,CAAC,SAChB,KAAK,UAAU,YACX,sBAAAA,QAAI,OAAO;AAAA,QACT,oBAAAC;AAAA,QACA,KAAK;AAAA,QACL,UAAU,YAAAC,QAAK,SAAS,SAAS,YAAAA,QAAK,KAAK,KAAK,KAAK,IAAI,CAAC;AAAA,MAC5D,CAAC,IACD,sBAAAF,QAAI,IAAI;AAAA,QACN,oBAAAC;AAAA,QACA,KAAK;AAAA,QACL,UAAU,YAAAC,QAAK,SAAS,SAAS,YAAAA,QAAK,KAAK,KAAK,KAAK,IAAI,CAAC;AAAA,MAC5D,CAAC;AAAA,IACP;AAAA,EACF;AAEA,aAAO,sBAAO;AAAA,IACZ,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
6
- "names": ["git", "fs", "path"]
4
+ "sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\n\nimport { type Identity, commit } from './commit';\nimport { findRoot } from './findRoot';\nimport { type ChangedFile, getChangedFiles } from './getChangedFiles';\n\ninterface CommitAllParameters {\n dir: string;\n message: string;\n author?: Identity;\n committer?: Identity;\n\n /**\n * File changes to exclude from the commit.\n *\n * Defaults to `[]` (no exclusions).\n */\n ignore?: ChangedFile[];\n}\n\n/**\n * Stages all changes and writes a commit to the local Git repository.\n */\nexport const commitAllChanges = async ({\n dir,\n message,\n\n author,\n committer,\n ignore,\n}: CommitAllParameters): Promise<string | undefined> => {\n const changedFiles = await getChangedFiles({ dir, ignore });\n\n if (!changedFiles.length) {\n return;\n }\n\n const gitRoot = await findRoot({ dir });\n\n if (!gitRoot) {\n throw new Error(`Could not find Git root from directory: ${dir}`);\n }\n\n await Promise.all(\n changedFiles.map(async (file) => {\n const relativePath = path.relative(dir, file.path);\n\n // Skipping file outside working directory, see https://github.com/seek-oss/skuba/pull/1269#discussion_r1335308704\n if (relativePath.startsWith('..')) {\n return;\n }\n\n return file.state === 'deleted'\n ? git.remove({\n fs,\n dir: gitRoot,\n filepath: file.path,\n })\n : git.add({\n fs,\n dir: gitRoot,\n filepath: file.path,\n });\n }),\n );\n\n return commit({\n dir: gitRoot,\n message,\n author,\n committer,\n });\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAEhB,oBAAsC;AACtC,sBAAyB;AACzB,6BAAkD;AAmB3C,MAAM,mBAAmB,OAAO;AAAA,EACrC;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AACF,MAAwD;AACtD,QAAM,eAAe,UAAM,wCAAgB,EAAE,KAAK,OAAO,CAAC;AAE1D,MAAI,CAAC,aAAa,QAAQ;AACxB;AAAA,EACF;AAEA,QAAM,UAAU,UAAM,0BAAS,EAAE,IAAI,CAAC;AAEtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,2CAA2C,GAAG,EAAE;AAAA,EAClE;AAEA,QAAM,QAAQ;AAAA,IACZ,aAAa,IAAI,OAAO,SAAS;AAC/B,YAAM,eAAe,YAAAA,QAAK,SAAS,KAAK,KAAK,IAAI;AAGjD,UAAI,aAAa,WAAW,IAAI,GAAG;AACjC;AAAA,MACF;AAEA,aAAO,KAAK,UAAU,YAClB,sBAAAC,QAAI,OAAO;AAAA,QACT,oBAAAC;AAAA,QACA,KAAK;AAAA,QACL,UAAU,KAAK;AAAA,MACjB,CAAC,IACD,sBAAAD,QAAI,IAAI;AAAA,QACN,oBAAAC;AAAA,QACA,KAAK;AAAA,QACL,UAAU,KAAK;AAAA,MACjB,CAAC;AAAA,IACP,CAAC;AAAA,EACH;AAEA,aAAO,sBAAO;AAAA,IACZ,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
6
+ "names": ["path", "git", "fs"]
7
7
  }
@@ -47,7 +47,8 @@ const getChangedFiles = async ({
47
47
  dir,
48
48
  ignore = []
49
49
  }) => {
50
- const allFiles = await import_isomorphic_git.default.statusMatrix({ fs: import_fs_extra.default, dir });
50
+ const gitRoot = await (0, import_isomorphic_git.findRoot)({ fs: import_fs_extra.default, filepath: dir });
51
+ const allFiles = await import_isomorphic_git.default.statusMatrix({ fs: import_fs_extra.default, dir: gitRoot || dir });
51
52
  return allFiles.filter(
52
53
  (row) => row[import_statusMatrix.HEAD] !== import_statusMatrix.UNMODIFIED || row[import_statusMatrix.WORKDIR] !== import_statusMatrix.UNMODIFIED || row[import_statusMatrix.STAGE] !== import_statusMatrix.UNMODIFIED
53
54
  ).map((row) => ({ path: row[import_statusMatrix.FILEPATH], state: mapState(row) })).filter(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/git/getChangedFiles.ts"],
4
- "sourcesContent": ["import fs from 'fs-extra';\nimport git from 'isomorphic-git';\n\nimport {\n ABSENT,\n FILEPATH,\n HEAD,\n MODIFIED,\n STAGE,\n UNMODIFIED,\n WORKDIR,\n} from './statusMatrix';\n\ntype ChangedFileState = 'added' | 'modified' | 'deleted';\nexport interface ChangedFile {\n path: string;\n state: ChangedFileState;\n}\ninterface ChangedFilesParameters {\n dir: string;\n\n /**\n * File changes to exclude from the result.\n *\n * Defaults to `[]` (no exclusions).\n */\n ignore?: ChangedFile[];\n}\n\nconst mapState = (\n row: [string, 0 | 1, 0 | 1 | 2, 0 | 1 | 2 | 3],\n): ChangedFileState => {\n if (row[HEAD] === ABSENT) {\n return 'added';\n }\n\n if (row[WORKDIR] === MODIFIED) {\n return 'modified';\n }\n\n return 'deleted';\n};\n\n/**\n * Returns all the files which have been added, modified or deleted in the\n * working directory of the local Git repository since the last commit.\n */\nexport const getChangedFiles = async ({\n dir,\n\n ignore = [],\n}: ChangedFilesParameters): Promise<ChangedFile[]> => {\n const allFiles = await git.statusMatrix({ fs, dir });\n return allFiles\n .filter(\n (row) =>\n row[HEAD] !== UNMODIFIED ||\n row[WORKDIR] !== UNMODIFIED ||\n row[STAGE] !== UNMODIFIED,\n )\n .map((row) => ({ path: row[FILEPATH], state: mapState(row) }))\n .filter(\n (changedFile) =>\n !ignore.some(\n (i) => i.path === changedFile.path && i.state === changedFile.state,\n ),\n );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAe;AACf,4BAAgB;AAEhB,0BAQO;AAkBP,MAAM,WAAW,CACf,QACqB;AACrB,MAAI,IAAI,wBAAI,MAAM,4BAAQ;AACxB,WAAO;AAAA,EACT;AAEA,MAAI,IAAI,2BAAO,MAAM,8BAAU;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAMO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EAEA,SAAS,CAAC;AACZ,MAAsD;AACpD,QAAM,WAAW,MAAM,sBAAAA,QAAI,aAAa,EAAE,oBAAAC,SAAI,IAAI,CAAC;AACnD,SAAO,SACJ;AAAA,IACC,CAAC,QACC,IAAI,wBAAI,MAAM,kCACd,IAAI,2BAAO,MAAM,kCACjB,IAAI,yBAAK,MAAM;AAAA,EACnB,EACC,IAAI,CAAC,SAAS,EAAE,MAAM,IAAI,4BAAQ,GAAG,OAAO,SAAS,GAAG,EAAE,EAAE,EAC5D;AAAA,IACC,CAAC,gBACC,CAAC,OAAO;AAAA,MACN,CAAC,MAAM,EAAE,SAAS,YAAY,QAAQ,EAAE,UAAU,YAAY;AAAA,IAChE;AAAA,EACJ;AACJ;",
6
- "names": ["git", "fs"]
4
+ "sourcesContent": ["import fs from 'fs-extra';\nimport git, { findRoot } from 'isomorphic-git';\n\nimport {\n ABSENT,\n FILEPATH,\n HEAD,\n MODIFIED,\n STAGE,\n UNMODIFIED,\n WORKDIR,\n} from './statusMatrix';\n\ntype ChangedFileState = 'added' | 'modified' | 'deleted';\nexport interface ChangedFile {\n path: string;\n state: ChangedFileState;\n}\ninterface ChangedFilesParameters {\n dir: string;\n\n /**\n * File changes to exclude from the result.\n *\n * Defaults to `[]` (no exclusions).\n */\n ignore?: ChangedFile[];\n}\n\nconst mapState = (\n row: [string, 0 | 1, 0 | 1 | 2, 0 | 1 | 2 | 3],\n): ChangedFileState => {\n if (row[HEAD] === ABSENT) {\n return 'added';\n }\n\n if (row[WORKDIR] === MODIFIED) {\n return 'modified';\n }\n\n return 'deleted';\n};\n\n/**\n * Returns all the files which have been added, modified or deleted in the\n * working directory of the local Git repository since the last commit.\n */\nexport const getChangedFiles = async ({\n dir,\n\n ignore = [],\n}: ChangedFilesParameters): Promise<ChangedFile[]> => {\n const gitRoot = await findRoot({ fs, filepath: dir });\n const allFiles = await git.statusMatrix({ fs, dir: gitRoot || dir });\n return allFiles\n .filter(\n (row) =>\n row[HEAD] !== UNMODIFIED ||\n row[WORKDIR] !== UNMODIFIED ||\n row[STAGE] !== UNMODIFIED,\n )\n .map((row) => ({ path: row[FILEPATH], state: mapState(row) }))\n .filter(\n (changedFile) =>\n !ignore.some(\n (i) => i.path === changedFile.path && i.state === changedFile.state,\n ),\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAe;AACf,4BAA8B;AAE9B,0BAQO;AAkBP,MAAM,WAAW,CACf,QACqB;AACrB,MAAI,IAAI,wBAAI,MAAM,4BAAQ;AACxB,WAAO;AAAA,EACT;AAEA,MAAI,IAAI,2BAAO,MAAM,8BAAU;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAMO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EAEA,SAAS,CAAC;AACZ,MAAsD;AACpD,QAAM,UAAU,UAAM,gCAAS,EAAE,oBAAAA,SAAI,UAAU,IAAI,CAAC;AACpD,QAAM,WAAW,MAAM,sBAAAC,QAAI,aAAa,EAAE,oBAAAD,SAAI,KAAK,WAAW,IAAI,CAAC;AACnE,SAAO,SACJ;AAAA,IACC,CAAC,QACC,IAAI,wBAAI,MAAM,kCACd,IAAI,2BAAO,MAAM,kCACjB,IAAI,yBAAK,MAAM;AAAA,EACnB,EACC,IAAI,CAAC,SAAS,EAAE,MAAM,IAAI,4BAAQ,GAAG,OAAO,SAAS,GAAG,EAAE,EAAE,EAC5D;AAAA,IACC,CAAC,gBACC,CAAC,OAAO;AAAA,MACN,CAAC,MAAM,EAAE,SAAS,YAAY,QAAQ,EAAE,UAAU,YAAY;AAAA,IAChE;AAAA,EACJ;AACJ;",
6
+ "names": ["fs", "git"]
7
7
  }
@@ -86,30 +86,22 @@ const readFileChanges = async (dir, changedFiles) => {
86
86
  { added: [], deleted: [] }
87
87
  );
88
88
  const gitRoot = await Git.findRoot({ dir });
89
- const toGitHubPath = (filePath) => {
90
- if (!gitRoot) {
91
- return filePath;
92
- }
93
- const pathDir = import_path.default.relative(gitRoot, dir);
94
- return import_path.default.join(pathDir, filePath);
95
- };
96
89
  const toRootPath = (filePath) => {
97
90
  if (!gitRoot) {
98
91
  return filePath;
99
92
  }
100
- const pathDir = import_path.default.resolve(gitRoot, dir);
101
- return import_path.default.join(pathDir, filePath);
93
+ return import_path.default.resolve(gitRoot, filePath);
102
94
  };
103
95
  const additions = await Promise.all(
104
96
  added.map(async (filePath) => ({
105
- path: toGitHubPath(filePath),
97
+ path: filePath,
106
98
  contents: await import_fs_extra.default.promises.readFile(toRootPath(filePath), {
107
99
  encoding: "base64"
108
100
  })
109
101
  }))
110
102
  );
111
103
  const deletions = deleted.map((filePath) => ({
112
- path: toGitHubPath(filePath)
104
+ path: filePath
113
105
  }));
114
106
  return {
115
107
  additions,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/github/push.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport type { CreateCommitOnBranchInput } from '@octokit/graphql-schema';\nimport fs from 'fs-extra';\n\nimport * as Git from '../git';\n\nimport { apiTokenFromEnvironment } from './environment';\nimport { graphql } from './octokit';\n\ninterface CreateCommitResult {\n createCommitOnBranch: {\n commit: {\n oid: string;\n };\n };\n}\n\ninterface UploadAllFileChangesParams {\n dir: string;\n /**\n * The branch name\n */\n branch: string;\n /**\n * The headline of the commit message\n */\n messageHeadline: string;\n\n /**\n * File changes to exclude from the upload.\n *\n * Defaults to `[]` (no exclusions).\n */\n ignore?: Git.ChangedFile[];\n /**\n * The body of the commit message\n */\n messageBody?: string;\n /**\n * Updates the local Git repository to match the new remote branch state\n */\n updateLocal?: boolean;\n}\n\n/**\n * Retrieves all file changes from the local Git repository using\n * `getChangedFiles`, then uploads the changes to a specified GitHub branch\n * using `uploadFileChanges`.\n *\n * Returns the commit ID, or `undefined` if there are no changes to commit.\n *\n * The file changes will appear as verified commits on GitHub.\n *\n * This will not update the local Git repository unless `updateLocal` is\n * specified.\n */\nexport const uploadAllFileChanges = async ({\n branch,\n dir,\n messageHeadline,\n\n ignore,\n messageBody,\n updateLocal = false,\n}: UploadAllFileChangesParams): Promise<string | undefined> => {\n const changedFiles = await Git.getChangedFiles({ dir, ignore });\n\n if (!changedFiles.length) {\n return;\n }\n\n const fileChanges = await readFileChanges(dir, changedFiles);\n\n const commitId = await uploadFileChanges({\n dir,\n branch,\n messageHeadline,\n messageBody,\n fileChanges,\n });\n\n if (updateLocal) {\n await Promise.all(\n [...fileChanges.additions, ...fileChanges.deletions].map((file) =>\n fs.rm(file.path),\n ),\n );\n\n await Git.fastForwardBranch({\n ref: branch,\n auth: { type: 'gitHubApp' },\n dir,\n });\n }\n\n return commitId;\n};\n\ninterface FileAddition {\n contents: unknown;\n path: string;\n}\n\ninterface FileDeletion {\n path: string;\n}\n\nexport interface FileChanges {\n additions: FileAddition[];\n deletions: FileDeletion[];\n}\n\n/**\n * Takes a list of `ChangedFiles`, reads them from the file system, and maps\n * them to GitHub GraphQL `FileChanges`.\n *\n * https://docs.github.com/en/graphql/reference/input-objects#filechanges\n */\nexport const readFileChanges = async (\n dir: string,\n changedFiles: Git.ChangedFile[],\n): Promise<FileChanges> => {\n const { added, deleted } = changedFiles.reduce<{\n added: string[];\n deleted: string[];\n }>(\n (files, changedFile) => {\n const filePath = changedFile.path;\n if (changedFile.state === 'deleted') {\n files.deleted.push(filePath);\n } else {\n files.added.push(filePath);\n }\n\n return files;\n },\n { added: [], deleted: [] },\n );\n\n const gitRoot = await Git.findRoot({ dir });\n\n const toGitHubPath = (filePath: string) => {\n if (!gitRoot) {\n return filePath;\n }\n\n const pathDir = path.relative(gitRoot, dir);\n\n return path.join(pathDir, filePath);\n };\n\n const toRootPath = (filePath: string) => {\n if (!gitRoot) {\n return filePath;\n }\n\n const pathDir = path.resolve(gitRoot, dir);\n\n return path.join(pathDir, filePath);\n };\n\n const additions: FileAddition[] = await Promise.all(\n added.map(async (filePath) => ({\n path: toGitHubPath(filePath),\n contents: await fs.promises.readFile(toRootPath(filePath), {\n encoding: 'base64',\n }),\n })),\n );\n\n const deletions: FileDeletion[] = deleted.map((filePath) => ({\n path: toGitHubPath(filePath),\n }));\n\n return {\n additions,\n deletions,\n };\n};\n\ninterface UploadFileChangesParams {\n dir: string;\n /**\n * The branch name\n */\n branch: string;\n /**\n * The headline of the commit message\n */\n messageHeadline: string;\n /**\n * The body of the commit message\n */\n messageBody?: string;\n /**\n * File additions and deletions\n */\n fileChanges: FileChanges;\n}\n\n/**\n * Uploads file changes from the local workspace to a specified GitHub branch.\n *\n * The file changes will appear as verified commits on GitHub.\n *\n * This will not update the local Git repository.\n */\nexport const uploadFileChanges = async ({\n dir,\n branch,\n messageHeadline,\n messageBody,\n fileChanges,\n}: UploadFileChangesParams): Promise<string> => {\n const authToken = apiTokenFromEnvironment();\n if (!authToken) {\n throw new Error(\n 'Could not read a GitHub API token from the environment. Please set GITHUB_API_TOKEN or GITHUB_TOKEN.',\n );\n }\n\n const [{ owner, repo }, headCommitId] = await Promise.all([\n Git.getOwnerAndRepo({ dir }),\n Git.getHeadCommitId({ dir }),\n ]);\n\n const input: CreateCommitOnBranchInput = {\n branch: {\n repositoryNameWithOwner: `${owner}/${repo}`,\n branchName: branch,\n },\n message: {\n headline: messageHeadline,\n body: messageBody,\n },\n expectedHeadOid: headCommitId,\n clientMutationId: 'skuba',\n fileChanges,\n };\n\n const result = await graphql<CreateCommitResult>(\n `\n mutation Mutation($input: CreateCommitOnBranchInput!) {\n createCommitOnBranch(input: $input) {\n commit {\n oid\n }\n }\n }\n `,\n {\n input,\n headers: {\n authorization: `Bearer ${authToken}`,\n },\n },\n );\n\n return result.createCommitOnBranch.commit.oid;\n};\n"],
5
- "mappings": ";;;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AAAA,MACzC,YAAY;AAAA,IACd;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,IACA,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB;AAAA,EACF;AAEA,QAAM,SAAS,UAAM;AAAA,IACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA;AAAA,MACE;AAAA,MACA,SAAS;AAAA,QACP,eAAe,UAAU,SAAS;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,qBAAqB,OAAO;AAC5C;",
4
+ "sourcesContent": ["import path from 'path';\n\nimport type { CreateCommitOnBranchInput } from '@octokit/graphql-schema';\nimport fs from 'fs-extra';\n\nimport * as Git from '../git';\n\nimport { apiTokenFromEnvironment } from './environment';\nimport { graphql } from './octokit';\n\ninterface CreateCommitResult {\n createCommitOnBranch: {\n commit: {\n oid: string;\n };\n };\n}\n\ninterface UploadAllFileChangesParams {\n dir: string;\n /**\n * The branch name\n */\n branch: string;\n /**\n * The headline of the commit message\n */\n messageHeadline: string;\n\n /**\n * File changes to exclude from the upload.\n *\n * Defaults to `[]` (no exclusions).\n */\n ignore?: Git.ChangedFile[];\n /**\n * The body of the commit message\n */\n messageBody?: string;\n /**\n * Updates the local Git repository to match the new remote branch state\n */\n updateLocal?: boolean;\n}\n\n/**\n * Retrieves all file changes from the local Git repository using\n * `getChangedFiles`, then uploads the changes to a specified GitHub branch\n * using `uploadFileChanges`.\n *\n * Returns the commit ID, or `undefined` if there are no changes to commit.\n *\n * The file changes will appear as verified commits on GitHub.\n *\n * This will not update the local Git repository unless `updateLocal` is\n * specified.\n */\nexport const uploadAllFileChanges = async ({\n branch,\n dir,\n messageHeadline,\n\n ignore,\n messageBody,\n updateLocal = false,\n}: UploadAllFileChangesParams): Promise<string | undefined> => {\n const changedFiles = await Git.getChangedFiles({ dir, ignore });\n\n if (!changedFiles.length) {\n return;\n }\n\n const fileChanges = await readFileChanges(dir, changedFiles);\n\n const commitId = await uploadFileChanges({\n dir,\n branch,\n messageHeadline,\n messageBody,\n fileChanges,\n });\n\n if (updateLocal) {\n await Promise.all(\n [...fileChanges.additions, ...fileChanges.deletions].map((file) =>\n fs.rm(file.path),\n ),\n );\n\n await Git.fastForwardBranch({\n ref: branch,\n auth: { type: 'gitHubApp' },\n dir,\n });\n }\n\n return commitId;\n};\n\ninterface FileAddition {\n contents: unknown;\n path: string;\n}\n\ninterface FileDeletion {\n path: string;\n}\n\nexport interface FileChanges {\n additions: FileAddition[];\n deletions: FileDeletion[];\n}\n\n/**\n * Takes a list of `ChangedFiles`, reads them from the file system, and maps\n * them to GitHub GraphQL `FileChanges`.\n *\n * https://docs.github.com/en/graphql/reference/input-objects#filechanges\n */\nexport const readFileChanges = async (\n dir: string,\n changedFiles: Git.ChangedFile[],\n): Promise<FileChanges> => {\n const { added, deleted } = changedFiles.reduce<{\n added: string[];\n deleted: string[];\n }>(\n (files, changedFile) => {\n const filePath = changedFile.path;\n if (changedFile.state === 'deleted') {\n files.deleted.push(filePath);\n } else {\n files.added.push(filePath);\n }\n\n return files;\n },\n { added: [], deleted: [] },\n );\n\n const gitRoot = await Git.findRoot({ dir });\n\n const toRootPath = (filePath: string) => {\n if (!gitRoot) {\n return filePath;\n }\n\n return path.resolve(gitRoot, filePath);\n };\n\n const additions: FileAddition[] = await Promise.all(\n added.map(async (filePath) => ({\n path: filePath,\n contents: await fs.promises.readFile(toRootPath(filePath), {\n encoding: 'base64',\n }),\n })),\n );\n\n const deletions: FileDeletion[] = deleted.map((filePath) => ({\n path: filePath,\n }));\n\n return {\n additions,\n deletions,\n };\n};\n\ninterface UploadFileChangesParams {\n dir: string;\n /**\n * The branch name\n */\n branch: string;\n /**\n * The headline of the commit message\n */\n messageHeadline: string;\n /**\n * The body of the commit message\n */\n messageBody?: string;\n /**\n * File additions and deletions\n */\n fileChanges: FileChanges;\n}\n\n/**\n * Uploads file changes from the local workspace to a specified GitHub branch.\n *\n * The file changes will appear as verified commits on GitHub.\n *\n * This will not update the local Git repository.\n */\nexport const uploadFileChanges = async ({\n dir,\n branch,\n messageHeadline,\n messageBody,\n fileChanges,\n}: UploadFileChangesParams): Promise<string> => {\n const authToken = apiTokenFromEnvironment();\n if (!authToken) {\n throw new Error(\n 'Could not read a GitHub API token from the environment. Please set GITHUB_API_TOKEN or GITHUB_TOKEN.',\n );\n }\n\n const [{ owner, repo }, headCommitId] = await Promise.all([\n Git.getOwnerAndRepo({ dir }),\n Git.getHeadCommitId({ dir }),\n ]);\n\n const input: CreateCommitOnBranchInput = {\n branch: {\n repositoryNameWithOwner: `${owner}/${repo}`,\n branchName: branch,\n },\n message: {\n headline: messageHeadline,\n body: messageBody,\n },\n expectedHeadOid: headCommitId,\n clientMutationId: 'skuba',\n fileChanges,\n };\n\n const result = await graphql<CreateCommitResult>(\n `\n mutation Mutation($input: CreateCommitOnBranchInput!) {\n createCommitOnBranch(input: $input) {\n commit {\n oid\n }\n }\n }\n `,\n {\n input,\n headers: {\n authorization: `Bearer ${authToken}`,\n },\n },\n );\n\n return result.createCommitOnBranch.commit.oid;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGjB,sBAAe;AAEf,UAAqB;AAErB,yBAAwC;AACxC,qBAAwB;AAiDjB,MAAM,uBAAuB,OAAO;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA,cAAc;AAChB,MAA+D;AAC7D,QAAM,eAAe,MAAM,IAAI,gBAAgB,EAAE,KAAK,OAAO,CAAC;AAE9D,MAAI,CAAC,aAAa,QAAQ;AACxB;AAAA,EACF;AAEA,QAAM,cAAc,MAAM,gBAAgB,KAAK,YAAY;AAE3D,QAAM,WAAW,MAAM,kBAAkB;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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,MAAM,oBAAoB,OAAO;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAgD;AAC9C,QAAM,gBAAY,4CAAwB;AAC1C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,CAAC,EAAE,OAAO,KAAK,GAAG,YAAY,IAAI,MAAM,QAAQ,IAAI;AAAA,IACxD,IAAI,gBAAgB,EAAE,IAAI,CAAC;AAAA,IAC3B,IAAI,gBAAgB,EAAE,IAAI,CAAC;AAAA,EAC7B,CAAC;AAED,QAAM,QAAmC;AAAA,IACvC,QAAQ;AAAA,MACN,yBAAyB,GAAG,KAAK,IAAI,IAAI;AAAA,MACzC,YAAY;AAAA,IACd;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,IACA,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB;AAAA,EACF;AAEA,QAAM,SAAS,UAAM;AAAA,IACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA;AAAA,MACE;AAAA,MACA,SAAS;AAAA,QACP,eAAe,UAAU,SAAS;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,qBAAqB,OAAO;AAC5C;",
6
6
  "names": ["fs", "path"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skuba",
3
- "version": "11.0.1-fix-nested-repo-usage-20250522060154",
3
+ "version": "11.0.1-monorepo-uploadAllFileChanges-20250523041813",
4
4
  "private": false,
5
5
  "description": "SEEK development toolkit for backend applications and packages",
6
6
  "homepage": "https://github.com/seek-oss/skuba#readme",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/node": "^22.13.10",
20
- "skuba": "11.0.1-fix-nested-repo-usage-20250522060154"
20
+ "skuba": "11.0.1-monorepo-uploadAllFileChanges-20250523041813"
21
21
  },
22
22
  "packageManager": "pnpm@10.10.0",
23
23
  "engines": {
@@ -37,7 +37,7 @@
37
37
  "constructs": "^10.0.17",
38
38
  "datadog-cdk-constructs-v2": "^2.0.0",
39
39
  "pino-pretty": "^13.0.0",
40
- "skuba": "11.0.1-fix-nested-repo-usage-20250522060154"
40
+ "skuba": "11.0.1-monorepo-uploadAllFileChanges-20250523041813"
41
41
  },
42
42
  "packageManager": "pnpm@10.10.0",
43
43
  "engines": {