@conduction/docusaurus-preset 2.7.0-beta.3 → 2.7.0-beta.4
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 +1 -1
- package/src/index.js +37 -21
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -42,31 +42,47 @@ function resolveAppVersion(opts) {
|
|
|
42
42
|
if (opts.appVersion) return String(opts.appVersion);
|
|
43
43
|
|
|
44
44
|
/* Nextcloud apps: appinfo/info.xml carries the canonical version.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
Conduction docs sites live at <appRepo>/docs/ next to the app's
|
|
46
|
+
<appRepo>/appinfo/, so we check both the cwd AND the parent
|
|
47
|
+
before giving up. We avoid pulling in an XML parser for one tag
|
|
48
|
+
— a non-greedy regex against the file content is robust enough
|
|
49
|
+
for the standard `<version>x.y.z</version>` shape the app store
|
|
50
|
+
mandates. */
|
|
51
|
+
const cwd = process.cwd();
|
|
52
|
+
const infoCandidates = [
|
|
53
|
+
path.join(cwd, 'appinfo', 'info.xml'),
|
|
54
|
+
path.join(cwd, '..', 'appinfo', 'info.xml'),
|
|
55
|
+
];
|
|
56
|
+
for (const infoPath of infoCandidates) {
|
|
57
|
+
try {
|
|
58
|
+
if (fs.existsSync(infoPath)) {
|
|
59
|
+
const xml = fs.readFileSync(infoPath, 'utf8');
|
|
60
|
+
const m = xml.match(/<version>\s*([^<\s]+)\s*<\/version>/);
|
|
61
|
+
if (m && m[1]) return m[1];
|
|
62
|
+
}
|
|
63
|
+
} catch (e) {
|
|
64
|
+
/* fall through */
|
|
54
65
|
}
|
|
55
|
-
} catch (e) {
|
|
56
|
-
/* fall through */
|
|
57
66
|
}
|
|
58
67
|
|
|
59
|
-
/* Non-Nextcloud sites: package.json version.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
/* Non-Nextcloud sites: package.json version. Same parent-walk so
|
|
69
|
+
a site building from <repo>/site/ still finds <repo>/package.json. */
|
|
70
|
+
const pkgCandidates = [
|
|
71
|
+
path.join(cwd, 'package.json'),
|
|
72
|
+
path.join(cwd, '..', 'package.json'),
|
|
73
|
+
];
|
|
74
|
+
for (const pkgPath of pkgCandidates) {
|
|
75
|
+
try {
|
|
76
|
+
if (fs.existsSync(pkgPath)) {
|
|
77
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
78
|
+
/* Skip the docs-site's own placeholder package.json (every
|
|
79
|
+
Conduction docs site is scaffolded with name="*-docs" and
|
|
80
|
+
version="0.0.0"); fall through to the parent in that case. */
|
|
81
|
+
if (pkg.version && pkg.version !== '0.0.0') return pkg.version;
|
|
82
|
+
}
|
|
83
|
+
} catch (e) {
|
|
84
|
+
/* fall through */
|
|
67
85
|
}
|
|
68
|
-
} catch (e) {
|
|
69
|
-
/* fall through */
|
|
70
86
|
}
|
|
71
87
|
|
|
72
88
|
return undefined;
|