docs-please 0.2.1-beta.0 → 0.2.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docs-please",
3
3
  "type": "module",
4
- "version": "0.2.1-beta.0",
4
+ "version": "0.2.2",
5
5
  "description": "Nuxt layer for documentation sites using shadcn-vue",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -18,7 +18,8 @@
18
18
  "modules",
19
19
  "nuxt.config.ts",
20
20
  "nuxt.schema.ts",
21
- "server"
21
+ "server",
22
+ "utils"
22
23
  ],
23
24
  "scripts": {
24
25
  "dev": "nuxt dev",
@@ -79,8 +80,5 @@
79
80
  "nuxt-llms": "^0.1.3",
80
81
  "typescript": "^5.9.3",
81
82
  "vue-tsc": "^2.0.0"
82
- },
83
- "publishConfig": {
84
- "tag": "beta"
85
83
  }
86
84
  }
package/utils/git.ts ADDED
@@ -0,0 +1,59 @@
1
+ import { execSync } from 'node:child_process'
2
+ import process from 'node:process'
3
+
4
+ export interface GitInfo {
5
+ name: string
6
+ owner: string
7
+ url: string
8
+ }
9
+
10
+ export function getGitBranch(): string {
11
+ const envName
12
+ = process.env.CF_PAGES_BRANCH
13
+ || process.env.CI_COMMIT_BRANCH
14
+ || process.env.VERCEL_GIT_COMMIT_REF
15
+ || process.env.BRANCH
16
+ || process.env.GITHUB_REF_NAME
17
+
18
+ if (envName && envName !== 'HEAD') {
19
+ return envName
20
+ }
21
+ try {
22
+ const branch = execSync('git rev-parse --abbrev-ref HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim()
23
+ if (branch && branch !== 'HEAD') {
24
+ return branch
25
+ }
26
+ }
27
+ catch {
28
+ // Ignore error
29
+ }
30
+
31
+ return 'main'
32
+ }
33
+
34
+ export function getGitEnv(): GitInfo {
35
+ const envInfo = {
36
+ provider: process.env.VERCEL_GIT_PROVIDER
37
+ || (process.env.GITHUB_SERVER_URL ? 'github' : undefined)
38
+ || '',
39
+ owner: process.env.VERCEL_GIT_REPO_OWNER
40
+ || process.env.GITHUB_REPOSITORY_OWNER
41
+ || process.env.CI_PROJECT_PATH?.split('/').shift()
42
+ || '',
43
+ name: process.env.VERCEL_GIT_REPO_SLUG
44
+ || process.env.GITHUB_REPOSITORY?.split('/').pop()
45
+ || process.env.CI_PROJECT_PATH?.split('/').splice(1).join('/')
46
+ || '',
47
+ url: process.env.REPOSITORY_URL || '',
48
+ }
49
+
50
+ if (!envInfo.url && envInfo.provider && envInfo.owner && envInfo.name) {
51
+ envInfo.url = `https://${envInfo.provider}.com/${envInfo.owner}/${envInfo.name}`
52
+ }
53
+
54
+ return {
55
+ name: envInfo.name,
56
+ owner: envInfo.owner,
57
+ url: envInfo.url,
58
+ }
59
+ }
package/utils/meta.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { readFile } from 'node:fs/promises'
2
+ import { resolve } from 'node:path'
3
+ import process from 'node:process'
4
+
5
+ export function inferSiteURL(): string | undefined {
6
+ return (
7
+ process.env.NUXT_SITE_URL
8
+ || (process.env.NEXT_PUBLIC_VERCEL_URL && `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`)
9
+ || process.env.URL // Netlify
10
+ || process.env.CI_PAGES_URL // Gitlab Pages
11
+ || process.env.CF_PAGES_URL // Cloudflare Pages
12
+ )
13
+ }
14
+
15
+ export async function getPackageJsonMetadata(dir: string): Promise<{ name: string, description?: string }> {
16
+ try {
17
+ const packageJson = await readFile(resolve(dir, 'package.json'), 'utf-8')
18
+ const parsed = JSON.parse(packageJson)
19
+ return {
20
+ name: parsed.name,
21
+ description: parsed.description,
22
+ }
23
+ }
24
+ catch {
25
+ return {
26
+ name: 'docs',
27
+ }
28
+ }
29
+ }