metaowl 0.1.0 → 0.1.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.
@@ -2,11 +2,11 @@
2
2
  /**
3
3
  * metaowl build — lint then production build.
4
4
  */
5
- import { banner, bin, cwd, metaowlRoot, run, success } from './utils.js'
5
+ import { banner, metaowlRoot, resolveBin, run, success } from './utils.js'
6
6
 
7
7
  banner('build')
8
8
  run('Linting', `node "${metaowlRoot}/bin/metaowl-lint.js"`)
9
- run('Building', `"${bin}/vite" build`)
9
+ run('Building', `"${resolveBin('vite')}" build`)
10
10
  success('Build complete')
11
11
  console.log()
12
12
 
@@ -3,10 +3,10 @@
3
3
  * metaowl dev — start the Vite development server.
4
4
  */
5
5
  import { execSync } from 'node:child_process'
6
- import { banner, bin, cwd, step } from './utils.js'
6
+ import { banner, cwd, resolveBin, step } from './utils.js'
7
7
 
8
8
  banner('dev')
9
9
  step('Starting development server...')
10
10
  console.log()
11
11
 
12
- execSync(`"${bin}/vite"`, { stdio: 'inherit', cwd })
12
+ execSync(`"${resolveBin('vite')}"`, { stdio: 'inherit', cwd })
@@ -13,7 +13,7 @@
13
13
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
14
14
  import { resolve } from 'node:path'
15
15
  import { globSync } from 'glob'
16
- import { banner, bin, cwd, metaowlRoot, run, step, success, failure } from './utils.js'
16
+ import { banner, cwd, metaowlRoot, resolveBin, run, step, success, failure } from './utils.js'
17
17
 
18
18
  banner('generate')
19
19
 
@@ -142,7 +142,7 @@ function buildShell(baseHtml, pageFile) {
142
142
  run('Linting', `node "${metaowlRoot}/bin/metaowl-lint.js"`)
143
143
 
144
144
  // 2. Vite build
145
- run('Building', `"${bin}/vite" build`)
145
+ run('Building', `"${resolveBin('vite')}" build`)
146
146
 
147
147
  // 3. SSG post-processing
148
148
  step('Generating static pages...')
@@ -12,7 +12,7 @@ import { execSync } from 'node:child_process'
12
12
  import { existsSync, readFileSync } from 'node:fs'
13
13
  import { resolve } from 'node:path'
14
14
  import { globSync } from 'glob'
15
- import { banner, bin, cwd, step, success, failure } from './utils.js'
15
+ import { banner, cwd, resolveBin, step, success, failure } from './utils.js'
16
16
 
17
17
  banner('lint')
18
18
 
@@ -49,7 +49,7 @@ const targets = existing.map(t => `"${t}"`).join(' ')
49
49
  step('Formatting with Prettier...')
50
50
  console.log()
51
51
  try {
52
- execSync(`"${bin}/prettier" src --single-quote --no-semi --write`, { stdio: 'inherit', cwd })
52
+ execSync(`"${resolveBin('prettier')}" src --single-quote --no-semi --write`, { stdio: 'inherit', cwd })
53
53
  } catch {
54
54
  failure('Prettier failed')
55
55
  process.exit(1)
@@ -59,7 +59,7 @@ console.log()
59
59
  step('Linting with ESLint...')
60
60
  console.log()
61
61
  try {
62
- execSync(`"${bin}/eslint" ${targets} --fix`, { stdio: 'inherit', cwd })
62
+ execSync(`"${resolveBin('eslint')}" ${targets} --fix`, { stdio: 'inherit', cwd })
63
63
  } catch {
64
64
  failure('ESLint failed')
65
65
  process.exit(1)
package/bin/utils.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Shared CLI utilities for metaowl bin scripts.
3
3
  * Uses ANSI escape codes only when stdout is a TTY (no color when piped).
4
4
  */
5
- import { readFileSync } from 'node:fs'
5
+ import { existsSync, readFileSync } from 'node:fs'
6
6
  import { resolve, dirname } from 'node:path'
7
7
  import { fileURLToPath } from 'node:url'
8
8
  import { execSync } from 'node:child_process'
@@ -10,10 +10,31 @@ import { execSync } from 'node:child_process'
10
10
  export const metaowlRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
11
11
  export const bin = resolve(metaowlRoot, 'node_modules/.bin')
12
12
  export const cwd = process.cwd()
13
+ const cwdBin = resolve(cwd, 'node_modules/.bin')
13
14
 
14
15
  const { version } = JSON.parse(readFileSync(resolve(metaowlRoot, 'package.json'), 'utf-8'))
15
16
  export { version }
16
17
 
18
+ /**
19
+ * Resolve an executable path with fallback for hoisted installs.
20
+ * Priority:
21
+ * 1) metaowl-local node_modules/.bin
22
+ * 2) project node_modules/.bin
23
+ * 3) command name (PATH lookup by shell)
24
+ *
25
+ * @param {string} name
26
+ * @returns {string}
27
+ */
28
+ export function resolveBin(name) {
29
+ const local = resolve(bin, name)
30
+ if (existsSync(local)) return local
31
+
32
+ const project = resolve(cwdBin, name)
33
+ if (existsSync(project)) return project
34
+
35
+ return name
36
+ }
37
+
17
38
  const TTY = Boolean(process.stdout.isTTY)
18
39
  const a = (str, code) => TTY ? `\x1b[${code}m${str}\x1b[0m` : str
19
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metaowl",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Lightweight meta-framework for Odoo OWL — file-based routing, app mounting, Fetch helper, Cache, Meta tags, SSG generator, and a Vite plugin.",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/vite/plugin.js CHANGED
@@ -1,11 +1,20 @@
1
1
  import { fileURLToPath } from 'node:url'
2
2
  import { resolve, dirname } from 'node:path'
3
3
  import { mkdirSync, copyFileSync, cpSync, existsSync } from 'node:fs'
4
+ import { createRequire } from 'node:module'
4
5
  import { globSync } from 'glob'
5
6
  import { config as dotenvConfig } from 'dotenv'
6
7
  import ViteRestart from 'vite-plugin-restart'
7
8
  import tsconfigPaths from 'vite-tsconfig-paths'
8
9
 
10
+ const require = createRequire(import.meta.url)
11
+
12
+ function resolveOwlPath() {
13
+ return require.resolve('@odoo/owl/dist/owl.es.js', {
14
+ paths: [process.cwd(), dirname(fileURLToPath(import.meta.url))]
15
+ })
16
+ }
17
+
9
18
  /**
10
19
  * Collect all .xml files from a directory glob and return them as
11
20
  * URL-style paths (e.g. /components/Header/Header.xml).
@@ -91,7 +100,7 @@ export function metaowlPlugin(options = {}) {
91
100
  cfg.publicDir = cfg.publicDir ?? publicDir
92
101
  cfg.appType = cfg.appType ?? 'spa'
93
102
 
94
- const owlPath = fileURLToPath(new URL('../node_modules/@odoo/owl/dist/owl.es.js', import.meta.url))
103
+ const owlPath = resolveOwlPath()
95
104
  cfg.resolve = {
96
105
  ...(cfg.resolve ?? {}),
97
106
  alias: {