@pie-element/cli 0.1.2-next.0 → 0.1.2-next.10

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/utils/git.js CHANGED
@@ -1,7 +1,19 @@
1
1
  import { execSync } from 'node:child_process';
2
+ /**
3
+ * The environment for a git subprocess aimed at a repository through `cwd`.
4
+ * A git hook exports `GIT_DIR`, which overrides `cwd`: from a worktree it is an
5
+ * absolute path, so `git init` in a temp dir re-initialises the hooked
6
+ * repository as bare and `rev-parse` reads the hooked repository's HEAD.
7
+ */
8
+ export function isolatedGitEnv(env = process.env) {
9
+ return Object.fromEntries(Object.entries(env).filter(([key]) => !key.startsWith('GIT_')));
10
+ }
11
+ function git(command, cwd) {
12
+ return execSync(`git ${command}`, { cwd, encoding: 'utf8', env: isolatedGitEnv() });
13
+ }
2
14
  export function getCurrentCommit(cwd) {
3
15
  try {
4
- return execSync('git rev-parse HEAD', { cwd, encoding: 'utf8' }).trim();
16
+ return git('rev-parse HEAD', cwd).trim();
5
17
  }
6
18
  catch (error) {
7
19
  throw new Error(`Failed to get current commit: ${error}`);
@@ -9,7 +21,7 @@ export function getCurrentCommit(cwd) {
9
21
  }
10
22
  export function getCurrentCommitShort(cwd) {
11
23
  try {
12
- return execSync('git rev-parse --short HEAD', { cwd, encoding: 'utf8' }).trim();
24
+ return git('rev-parse --short HEAD', cwd).trim();
13
25
  }
14
26
  catch (error) {
15
27
  throw new Error(`Failed to get short commit: ${error}`);
@@ -17,10 +29,7 @@ export function getCurrentCommitShort(cwd) {
17
29
  }
18
30
  export function getCommitsSince(since, cwd) {
19
31
  try {
20
- const output = execSync(`git log ${since}..HEAD --oneline`, {
21
- cwd,
22
- encoding: 'utf8',
23
- }).trim();
32
+ const output = git(`log ${since}..HEAD --oneline`, cwd).trim();
24
33
  if (!output)
25
34
  return [];
26
35
  return output.split('\n');
@@ -31,10 +40,7 @@ export function getCommitsSince(since, cwd) {
31
40
  }
32
41
  export function getFileModifiedDate(filePath, cwd) {
33
42
  try {
34
- const timestamp = execSync(`git log -1 --format=%ct -- "${filePath}"`, {
35
- cwd,
36
- encoding: 'utf8',
37
- }).trim();
43
+ const timestamp = git(`log -1 --format=%ct -- "${filePath}"`, cwd).trim();
38
44
  return new Date(Number.parseInt(timestamp, 10) * 1000);
39
45
  }
40
46
  catch (error) {
@@ -43,10 +49,7 @@ export function getFileModifiedDate(filePath, cwd) {
43
49
  }
44
50
  export function getCommitDetails(commit, cwd) {
45
51
  try {
46
- return execSync(`git show --stat ${commit}`, {
47
- cwd,
48
- encoding: 'utf8',
49
- });
52
+ return git(`show --stat ${commit}`, cwd);
50
53
  }
51
54
  catch (error) {
52
55
  throw new Error(`Failed to get commit details: ${error}`);
@@ -54,7 +57,7 @@ export function getCommitDetails(commit, cwd) {
54
57
  }
55
58
  export function getAuthorName(cwd) {
56
59
  try {
57
- return execSync('git config user.name', { cwd, encoding: 'utf8' }).trim();
60
+ return git('config user.name', cwd).trim();
58
61
  }
59
62
  catch (_error) {
60
63
  return 'Unknown';
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,oBAAoB,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,4BAA4B,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,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,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,sBAAsB,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5E,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { execSync } from 'node:child_process';\n\nexport function getCurrentCommit(cwd: string): string {\n try {\n return execSync('git rev-parse HEAD', { cwd, encoding: 'utf8' }).trim();\n } catch (error) {\n throw new Error(`Failed to get current commit: ${error}`);\n }\n}\n\nexport function getCurrentCommitShort(cwd: string): string {\n try {\n return execSync('git rev-parse --short HEAD', { cwd, encoding: 'utf8' }).trim();\n } catch (error) {\n throw new Error(`Failed to get short commit: ${error}`);\n }\n}\n\nexport function getCommitsSince(since: string, cwd: string): string[] {\n try {\n const output = execSync(`git log ${since}..HEAD --oneline`, {\n cwd,\n encoding: 'utf8',\n }).trim();\n\n if (!output) return [];\n return output.split('\\n');\n } catch (error) {\n throw new Error(`Failed to get commits since ${since}: ${error}`);\n }\n}\n\nexport function getFileModifiedDate(filePath: string, cwd: string): Date {\n try {\n const timestamp = execSync(`git log -1 --format=%ct -- \"${filePath}\"`, {\n cwd,\n encoding: 'utf8',\n }).trim();\n\n return new Date(Number.parseInt(timestamp, 10) * 1000);\n } catch (error) {\n throw new Error(`Failed to get file modification date: ${error}`);\n }\n}\n\nexport function getCommitDetails(commit: string, cwd: string): string {\n try {\n return execSync(`git show --stat ${commit}`, {\n cwd,\n encoding: 'utf8',\n });\n } catch (error) {\n throw new Error(`Failed to get commit details: ${error}`);\n }\n}\n\nexport function getAuthorName(cwd: string): string {\n try {\n return execSync('git config user.name', { cwd, encoding: 'utf8' }).trim();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for a git subprocess aimed at a repository through `cwd`.\n * A git hook exports `GIT_DIR`, which overrides `cwd`: from a worktree it is an\n * absolute path, so `git init` in a temp dir re-initialises the hooked\n * repository as bare and `rev-parse` reads the hooked repository's HEAD.\n */\nexport function isolatedGitEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {\n return Object.fromEntries(Object.entries(env).filter(([key]) => !key.startsWith('GIT_')));\n}\n\nfunction git(command: string, cwd: string): string {\n return execSync(`git ${command}`, { cwd, encoding: 'utf8', env: isolatedGitEnv() });\n}\n\nexport function getCurrentCommit(cwd: string): string {\n try {\n return git('rev-parse HEAD', cwd).trim();\n } catch (error) {\n throw new Error(`Failed to get current commit: ${error}`);\n }\n}\n\nexport function getCurrentCommitShort(cwd: string): string {\n try {\n return git('rev-parse --short HEAD', cwd).trim();\n } catch (error) {\n throw new Error(`Failed to get short commit: ${error}`);\n }\n}\n\nexport function getCommitsSince(since: string, cwd: string): string[] {\n try {\n const output = git(`log ${since}..HEAD --oneline`, cwd).trim();\n\n if (!output) return [];\n return output.split('\\n');\n } catch (error) {\n throw new Error(`Failed to get commits since ${since}: ${error}`);\n }\n}\n\nexport function getFileModifiedDate(filePath: string, cwd: string): Date {\n try {\n const timestamp = git(`log -1 --format=%ct -- \"${filePath}\"`, cwd).trim();\n\n return new Date(Number.parseInt(timestamp, 10) * 1000);\n } catch (error) {\n throw new Error(`Failed to get file modification date: ${error}`);\n }\n}\n\nexport function getCommitDetails(commit: string, cwd: string): string {\n try {\n return git(`show --stat ${commit}`, cwd);\n } catch (error) {\n throw new Error(`Failed to get commit details: ${error}`);\n }\n}\n\nexport function getAuthorName(cwd: string): string {\n try {\n return git('config user.name', cwd).trim();\n } catch (_error) {\n return 'Unknown';\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/cli",
3
- "version": "0.1.2-next.0",
3
+ "version": "0.1.2-next.10",
4
4
  "description": "CLI tools for managing PIE Elements NG",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,17 +23,12 @@
23
23
  "dependencies": {
24
24
  "@oclif/core": "^4.0.0",
25
25
  "@oclif/plugin-help": "^6.2.0",
26
- "@pie-element/element-bundler": "0.1.2-next.0",
26
+ "@pie-element/element-bundler": "0.1.2-next.4",
27
27
  "es-module-lexer": "^1.7.0",
28
28
  "glob": "^13.0.0",
29
29
  "open": "^10.0.3",
30
30
  "webpack": "^5.104.1"
31
31
  },
32
- "devDependencies": {
33
- "@types/node": "^25.0.3",
34
- "bun-types": "^1.3.11",
35
- "typescript": "^5.9.3"
36
- },
37
32
  "oclif": {
38
33
  "bin": "pie-cli",
39
34
  "dirname": "pie-cli",