18.0 vanilla

This commit is contained in:
Ernad Husremovic 2025-10-03 18:06:50 +02:00
parent d72e748793
commit 0a7ae8db93
337 changed files with 399651 additions and 232598 deletions

View file

@ -127,7 +127,7 @@ EXPORT_FCT_RE = re.compile(r"""
(?P<space>\s*) # space and empty line
export\s+ # export
(?P<type>(async\s+)?function)\s+ # async function or function
(?P<identifier>\w+) # name the function
(?P<identifier>[\w$]+) # name of the function
""", re.MULTILINE | re.VERBOSE)
@ -156,7 +156,7 @@ EXPORT_CLASS_RE = re.compile(r"""
(?P<space>\s*) # space and empty line
export\s+ # export
(?P<type>class)\s+ # class
(?P<identifier>\w+) # name of the class
(?P<identifier>[\w$]+) # name of the class
""", re.MULTILINE | re.VERBOSE)
@ -181,7 +181,7 @@ EXPORT_FCT_DEFAULT_RE = re.compile(r"""
(?P<space>\s*) # space and empty line
export\s+default\s+ # export default
(?P<type>(async\s+)?function)\s+ # async function or function
(?P<identifier>\w+) # name of the function
(?P<identifier>[\w$]+) # name of the function
""", re.MULTILINE | re.VERBOSE)
@ -210,7 +210,7 @@ EXPORT_CLASS_DEFAULT_RE = re.compile(r"""
(?P<space>\s*) # space and empty line
export\s+default\s+ # export default
(?P<type>class)\s+ # class
(?P<identifier>\w+) # name of the class or the function
(?P<identifier>[\w$]+) # name of the class or the function
""", re.MULTILINE | re.VERBOSE)
@ -234,7 +234,7 @@ EXPORT_VAR_RE = re.compile(r"""
(?P<space>\s*) # space and empty line
export\s+ # export
(?P<type>let|const|var)\s+ # let or cont or var
(?P<identifier>\w+) # variable name
(?P<identifier>[\w$]+) # variable name
""", re.MULTILINE | re.VERBOSE)
@ -260,7 +260,7 @@ EXPORT_DEFAULT_VAR_RE = re.compile(r"""
(?P<space>\s*) # space and empty line
export\s+default\s+ # export default
(?P<type>let|const|var)\s+ # let or const or var
(?P<identifier>\w+)\s* # variable name
(?P<identifier>[\w$]+)\s* # variable name
""", re.MULTILINE | re.VERBOSE)
@ -284,7 +284,7 @@ EXPORT_OBJECT_RE = re.compile(r"""
^
(?P<space>\s*) # space and empty line
export\s* # export
(?P<object>{[\w\s,]+}) # { a, b, c as x, ... }
(?P<object>{[\w$\s,]+}) # { a, b, c as x, ... }
""", re.MULTILINE | re.VERBOSE)
@ -310,7 +310,7 @@ EXPORT_FROM_RE = re.compile(r"""
^
(?P<space>\s*) # space and empty line
export\s* # export
(?P<object>{[\w\s,]+})\s* # { a, b, c as x, ... }
(?P<object>{[\w$\s,]+})\s* # { a, b, c as x, ... }
from\s* # from
(?P<path>(?P<quote>["'`])([^"'`]+)(?P=quote)) # "file path" ("some/path.js")
""", re.MULTILINE | re.VERBOSE)
@ -366,7 +366,7 @@ EXPORT_DEFAULT_RE = re.compile(r"""
^
(?P<space>\s*) # space and empty line
export\s+default # export default
(\s+\w+\s*=)? # something (optional)
(\s+[\w$]+\s*=)? # something (optional)
""", re.MULTILINE | re.VERBOSE)
@ -402,7 +402,7 @@ IMPORT_BASIC_RE = re.compile(r"""
^
(?P<space>\s*) # space and empty line
import\s+ # import
(?P<object>{[\s\w,]+})\s* # { a, b, c as x, ... }
(?P<object>{[\s\w$,]+})\s* # { a, b, c as x, ... }
from\s* # from
(?P<path>(?P<quote>["'`])([^"'`]+)(?P=quote)) # "file path" ("some/path")
""", re.MULTILINE | re.VERBOSE)
@ -429,7 +429,7 @@ IMPORT_LEGACY_DEFAULT_RE = re.compile(r"""
^
(?P<space>\s*) # space and empty line
import\s+ # import
(?P<identifier>\w+)\s* # default variable name
(?P<identifier>[\w$]+)\s* # default variable name
from\s* # from
(?P<path>(?P<quote>["'`])([^@\."'`][^"'`]*)(?P=quote)) # legacy alias file ("addon_name.module_name" or "some/path")
""", re.MULTILINE | re.VERBOSE)
@ -456,7 +456,7 @@ IMPORT_DEFAULT = re.compile(r"""
^
(?P<space>\s*) # space and empty line
import\s+ # import
(?P<identifier>\w+)\s* # default variable name
(?P<identifier>[\w$]+)\s* # default variable name
from\s* # from
(?P<path>(?P<quote>["'`])([^"'`]+)(?P=quote)) # "file path" ("some/path")
""", re.MULTILINE | re.VERBOSE)
@ -483,8 +483,8 @@ IMPORT_DEFAULT_AND_NAMED_RE = re.compile(r"""
^
(?P<space>\s*) # space and empty line
import\s+ # import
(?P<default_export>\w+)\s*,\s* # default variable name,
(?P<named_exports>{[\s\w,]+})\s* # { a, b, c as x, ... }
(?P<default_export>[\w$]+)\s*,\s* # default variable name,
(?P<named_exports>{[\s\w$,]+})\s* # { a, b, c as x, ... }
from\s* # from
(?P<path>(?P<quote>["'`])([^"'`]+)(?P=quote)) # "file path" ("some/path")
""", re.MULTILINE | re.VERBOSE)
@ -552,11 +552,11 @@ def convert_relative_require(url, dependencies, content):
IMPORT_STAR = re.compile(r"""
^(?P<space>\s*) # indentation
import\s+\*\s+as\s+ # import * as
(?P<identifier>\w+) # alias
\s*from\s* # from
(?P<path>[^;\n]+) # path
^(?P<space>\s*) # indentation
import\s+\*\s+as\s+ # import * as
(?P<identifier>[\w$]+) # alias
\s*from\s* # from
(?P<path>[^;\n]+) # path
""", re.MULTILINE | re.VERBOSE)
@ -576,13 +576,13 @@ def convert_star_import(content):
IMPORT_DEFAULT_AND_STAR = re.compile(r"""
^(?P<space>\s*) # indentation
import\s+ # import
(?P<default_export>\w+)\s*,\s* # default export name,
\*\s+as\s+ # * as
(?P<named_exports_alias>\w+) # alias
\s*from\s* # from
(?P<path>[^;\n]+) # path
^(?P<space>\s*) # indentation
import\s+ # import
(?P<default_export>[\w$]+)\s*,\s* # default export name,
\*\s+as\s+ # * as
(?P<named_exports_alias>[\w$]+) # alias
\s*from\s* # from
(?P<path>[^;\n]+) # path
""", re.MULTILINE | re.VERBOSE)
@ -662,23 +662,31 @@ def relative_path_to_module_path(url, path_rel):
ODOO_MODULE_RE = re.compile(r"""
\s* # some starting space
\/(\*|\/).*\s* # // or /*
@odoo-module # @odoo-module
(\s+alias=(?P<alias>[\w.]+))? # alias=web.AbstractAction (optional)
(\s+default=(?P<default>False|false|0))? # default=False or false or 0 (optional)
\s* # starting white space
\/(\*|\/) # /* or //
.* # any comment in between (optional)
@odoo-module # '@odoo-module' statement
(?P<ignore>\s+ignore)? # module in src | tests which should not be transpiled (optional)
(\s+alias=(?P<alias>[^\s*]+))? # alias (e.g. alias=web.Widget, alias=@web/../tests/utils) (optional)
(\s+default=(?P<default>[\w$]+))? # no implicit default export (e.g. default=false) (optional)
""", re.VERBOSE)
def is_odoo_module(content):
def is_odoo_module(url, content):
"""
Detect if the file is a native odoo module.
We look for a comment containing @odoo-module.
:param url:
:param content: source code
:return: is this a odoo module that need transpilation ?
"""
result = ODOO_MODULE_RE.match(content)
if result and result['ignore']:
return False
addon = url.split('/')[1]
if url.startswith(f'/{addon}/static/src') or url.startswith(f'/{addon}/static/tests'):
return True
return bool(result)