@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +37 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduction/docusaurus-preset",
3
- "version": "2.7.0-beta.3",
3
+ "version": "2.7.0-beta.4",
4
4
  "scripts": {
5
5
  "prepack": "node scripts/prepack-bundle-css.js"
6
6
  },
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
- We avoid pulling in an XML parser for one tag — a non-greedy regex
46
- against the file content is robust enough for the standard
47
- `<version>x.y.z</version>` shape the app store mandates. */
48
- try {
49
- const infoPath = path.join(process.cwd(), 'appinfo', 'info.xml');
50
- if (fs.existsSync(infoPath)) {
51
- const xml = fs.readFileSync(infoPath, 'utf8');
52
- const m = xml.match(/<version>\s*([^<\s]+)\s*<\/version>/);
53
- if (m && m[1]) return m[1];
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. Walks up from cwd in
60
- case the site builds from a sub-directory; one level deep is
61
- enough for the conduction-website layout. */
62
- try {
63
- const pkgPath = path.join(process.cwd(), 'package.json');
64
- if (fs.existsSync(pkgPath)) {
65
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
66
- if (pkg.version) return pkg.version;
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;