@dword-design/base-config-nuxt 3.2.17 → 4.0.1
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/dist/analyze.js +2 -4
- package/dist/depcheck-special.js +2 -2
- package/dist/dev.js +17 -11
- package/dist/eslint.config.js +3 -0
- package/dist/index.js +74 -9
- package/dist/modules/project/index.js +53 -76
- package/dist/modules/project/modules/express/handler.js +29 -0
- package/dist/modules/project/modules/express/index.js +18 -0
- package/dist/modules/project/modules/i18n/index.js +20 -68
- package/dist/modules/project/modules/locale-link/index.js +13 -11
- package/dist/modules/project/modules/locale-link/plugin.js +3 -3
- package/dist/modules/project/modules/svg.js +5 -0
- package/dist/nuxt-wrapper.js +10 -0
- package/dist/prepublish-only.js +19 -12
- package/dist/start.js +12 -16
- package/package.json +20 -26
- package/dist/get-nuxt-config.js +0 -9
- package/dist/modules/project/modules/axios-dynamic-baseurl/index.js +0 -6
- package/dist/modules/project/modules/axios-dynamic-baseurl/plugin.js +0 -5
- package/dist/modules/project/modules/babel.js +0 -3
- package/dist/modules/project/modules/body-parser.js +0 -6
- package/dist/modules/project/modules/css-modules.js +0 -4
- package/dist/modules/project/modules/dotenv.js +0 -6
- package/dist/modules/project/modules/i18n/missing-nuxt-i18n-head-error.js +0 -17
- package/dist/modules/project/modules/raw.js +0 -10
- package/dist/modules/project/modules/server-middleware/index.js +0 -27
- package/dist/modules/project/style.css +0 -3
- /package/dist/modules/project/modules/locale-link/{nuxt-locale-link.vue → component.vue} +0 -0
package/dist/analyze.js
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default (() =>
|
|
3
|
-
stdio: 'inherit'
|
|
4
|
-
}));
|
|
1
|
+
import { execaCommand } from 'execa';
|
|
2
|
+
export default (() => execaCommand('nuxt build --analyze'));
|
package/dist/depcheck-special.js
CHANGED
|
@@ -5,14 +5,14 @@ import jitiBabelTransform from '@dword-design/jiti-babel-transform';
|
|
|
5
5
|
import jiti from 'jiti';
|
|
6
6
|
import P from 'path';
|
|
7
7
|
export default (path => {
|
|
8
|
-
if (P.basename(path) === '
|
|
8
|
+
if (P.basename(path) === 'config.js') {
|
|
9
9
|
var _ref, _modules;
|
|
10
10
|
const jitiInstance = jiti(process.cwd(), {
|
|
11
11
|
esmResolve: true,
|
|
12
12
|
interopDefault: true,
|
|
13
13
|
transform: jitiBabelTransform
|
|
14
14
|
});
|
|
15
|
-
const config = jitiInstance('./
|
|
15
|
+
const config = jitiInstance('./config.js');
|
|
16
16
|
const modules = [...(config.modules || []), ...(config.buildModules || [])];
|
|
17
17
|
return _ref = (_modules = modules, map(mod => {
|
|
18
18
|
var _concat;
|
package/dist/dev.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
const _require = createRequire(import.meta.url);
|
|
4
|
+
const nuxtWrapper = _require.resolve('./nuxt-wrapper.js');
|
|
5
|
+
export default ((options = {}) => {
|
|
6
|
+
options = {
|
|
7
|
+
log: process.env.NODE_ENV !== 'test',
|
|
8
|
+
telemetry: process.env.NODE_ENV !== 'test',
|
|
9
|
+
...options
|
|
10
|
+
};
|
|
11
|
+
return execa(nuxtWrapper, ['dev'], {
|
|
12
|
+
[options.log ? 'stdio' : 'stderr']: 'inherit',
|
|
13
|
+
...(options.telemetry ? {} : {
|
|
14
|
+
env: {
|
|
15
|
+
NUXT_TELEMETRY_DISABLED: 1
|
|
16
|
+
}
|
|
17
|
+
})
|
|
9
18
|
});
|
|
10
|
-
await new Builder(nuxt).build();
|
|
11
|
-
await nuxt.listen();
|
|
12
|
-
return nuxt;
|
|
13
19
|
});
|
package/dist/eslint.config.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import depcheckParserSass from '@dword-design/depcheck-parser-sass';
|
|
2
|
+
import endent from "@dword-design/functions/dist/endent.js";
|
|
2
3
|
import packageName from 'depcheck-package-name';
|
|
3
4
|
import depcheckParserVue from 'depcheck-parser-vue';
|
|
4
|
-
import
|
|
5
|
+
import { globby } from 'globby';
|
|
6
|
+
import { createRequire } from 'module';
|
|
7
|
+
import outputFiles from 'output-files';
|
|
8
|
+
import P from 'path';
|
|
5
9
|
import analyze from "./analyze.js";
|
|
6
10
|
import depcheckSpecial from "./depcheck-special.js";
|
|
7
11
|
import dev from "./dev.js";
|
|
8
12
|
import eslintConfig from "./eslint.config.js";
|
|
9
|
-
import getNuxtConfig from "./get-nuxt-config.js";
|
|
10
13
|
import lint from "./lint.js";
|
|
11
14
|
import prepublishOnly from "./prepublish-only.js";
|
|
12
15
|
import start from "./start.js";
|
|
13
|
-
|
|
16
|
+
const _require = createRequire(import.meta.url);
|
|
14
17
|
export default {
|
|
15
|
-
allowedMatches: ['.stylelintrc.json', 'api', 'assets', 'components', 'content', 'i18n', 'layouts', 'middleware', 'model', 'modules', '
|
|
18
|
+
allowedMatches: ['.stylelintrc.json', 'api', 'assets', 'components', 'content', 'i18n', 'layouts', 'middleware', 'model', 'modules', 'config.js', 'pages', 'plugins', 'static', 'store', 'types'],
|
|
16
19
|
commands: {
|
|
17
20
|
analyze,
|
|
18
21
|
dev,
|
|
@@ -26,16 +29,78 @@ export default {
|
|
|
26
29
|
},
|
|
27
30
|
specials: [depcheckSpecial]
|
|
28
31
|
},
|
|
29
|
-
editorIgnore: ['.eslintcache', '.stylelintrc.json', '.nuxt', 'dist'],
|
|
32
|
+
editorIgnore: ['.eslintcache', '.stylelintcache', '.stylelintrc.json', '.nuxt', 'app.vue', 'dist', 'nuxt.config.js'],
|
|
30
33
|
eslintConfig,
|
|
31
|
-
gitignore: ['/.eslintcache', '/.nuxt', '/dist'],
|
|
34
|
+
gitignore: ['/.eslintcache', '/.nuxt', '/.stylelintcache', '/app.vue', '/dist', '/nuxt.config.js'],
|
|
32
35
|
lint,
|
|
36
|
+
nodeVersion: 18,
|
|
33
37
|
npmPublish: true,
|
|
34
38
|
packageConfig: {
|
|
35
39
|
main: 'dist/index.js'
|
|
36
40
|
},
|
|
37
|
-
prepare: () =>
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
prepare: async () => {
|
|
42
|
+
const projectModulePath = `./${P.relative(process.cwd(), _require.resolve('./modules/project/index.js')).split(P.sep).join('/')}`;
|
|
43
|
+
const translations = await globby('i18n/*.json');
|
|
44
|
+
const hasI18n = translations.length > 0;
|
|
45
|
+
await outputFiles({
|
|
46
|
+
'.stylelintrc.json': JSON.stringify({
|
|
47
|
+
extends: packageName`@dword-design/stylelint-config`
|
|
48
|
+
}, undefined, 2),
|
|
49
|
+
'app.vue': endent`
|
|
50
|
+
<template>
|
|
51
|
+
<NuxtLayout>
|
|
52
|
+
<NuxtPage />
|
|
53
|
+
</NuxtLayout>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script setup>
|
|
57
|
+
import { ${['useHead', ...(hasI18n ? ['useLocaleHead'] : []), 'useRuntimeConfig'].join(', ')} } from '#imports'
|
|
58
|
+
|
|
59
|
+
${[hasI18n ? ['const i18nHead = useLocaleHead({ addSeoAttributes: true })'] : [], 'const runtimeConfig = useRuntimeConfig()'].join('\n')}
|
|
60
|
+
|
|
61
|
+
useHead({
|
|
62
|
+
${[...(hasI18n ? [endent`
|
|
63
|
+
htmlAttrs: {
|
|
64
|
+
lang: i18nHead.value.htmlAttrs.lang,
|
|
65
|
+
},
|
|
66
|
+
link: i18nHead.value.link,
|
|
67
|
+
meta: i18nHead.value.meta,
|
|
68
|
+
`] : []), "titleTemplate: title => title ? `${title} | ${runtimeConfig.public.name}` : `${runtimeConfig.public.name}${runtimeConfig.public.title ? `: ${runtimeConfig.public.title}` : ''}`"].join('\n')}
|
|
69
|
+
})
|
|
70
|
+
</script>
|
|
71
|
+
`,
|
|
72
|
+
'nuxt.config.js': endent`
|
|
73
|
+
import projectModule from '${projectModulePath}'
|
|
74
|
+
import jiti from 'jiti'
|
|
75
|
+
import dotenv from '@dword-design/dotenv-json-extended'
|
|
76
|
+
import jitiBabelTransform from '@dword-design/jiti-babel-transform'
|
|
77
|
+
|
|
78
|
+
dotenv.config()
|
|
79
|
+
|
|
80
|
+
let options
|
|
81
|
+
try {
|
|
82
|
+
const jitiInstance = jiti(process.cwd(), {
|
|
83
|
+
esmResolve: true,
|
|
84
|
+
interopDefault: true,
|
|
85
|
+
transform: jitiBabelTransform,
|
|
86
|
+
})
|
|
87
|
+
options = jitiInstance('./config.js')
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error.message.startsWith("Cannot find module './config.js'\\n")) {
|
|
90
|
+
options = {}
|
|
91
|
+
} else {
|
|
92
|
+
throw error
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default {
|
|
97
|
+
modules: [
|
|
98
|
+
[projectModule, options],
|
|
99
|
+
],
|
|
100
|
+
}
|
|
101
|
+
`
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
supportedNodeVersions: [16, 18],
|
|
40
105
|
useJobMatrix: true
|
|
41
106
|
};
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import join from "@dword-design/functions/dist/join.js";
|
|
2
|
-
import keys from "@dword-design/functions/dist/keys.js";
|
|
3
|
-
import map from "@dword-design/functions/dist/map.js";
|
|
4
1
|
import omit from "@dword-design/functions/dist/omit.js";
|
|
5
|
-
import
|
|
2
|
+
import { addPlugin, addTemplate, installModule } from '@nuxt/kit';
|
|
6
3
|
import packageName from 'depcheck-package-name';
|
|
7
|
-
import jiti from 'jiti';
|
|
8
4
|
import { createRequire } from 'module';
|
|
9
|
-
import nuxtPushPlugins from 'nuxt-push-plugins';
|
|
10
5
|
import P from 'path';
|
|
11
|
-
import
|
|
12
|
-
import axiosDynamicBaseurlModule from "./modules/axios-dynamic-baseurl/index.js";
|
|
13
|
-
import babelModule from "./modules/babel.js";
|
|
14
|
-
import bodyParserModule from "./modules/body-parser.js";
|
|
15
|
-
import cssModulesModule from "./modules/css-modules.js";
|
|
16
|
-
import dotenvModule from "./modules/dotenv.js";
|
|
6
|
+
import expressModule from "./modules/express/index.js";
|
|
17
7
|
import i18nModule from "./modules/i18n/index.js";
|
|
18
8
|
import localeLinkModule from "./modules/locale-link/index.js";
|
|
19
|
-
import
|
|
20
|
-
import serverMiddlewareModule from "./modules/server-middleware/index.js";
|
|
9
|
+
import svgModule from "./modules/svg.js";
|
|
21
10
|
const _require = createRequire(import.meta.url);
|
|
22
|
-
export default async
|
|
23
|
-
var _ref, _projectConfig$router, _projectConfig, _defaultConfig$this$o, _ref2;
|
|
11
|
+
export default (async (options, nuxt) => {
|
|
24
12
|
const defaultConfig = {
|
|
25
13
|
bodyAttrs: {},
|
|
26
|
-
css: [
|
|
14
|
+
css: [],
|
|
27
15
|
head: {},
|
|
28
16
|
headAttrs: {},
|
|
29
17
|
htmlAttrs: {},
|
|
@@ -31,94 +19,83 @@ export default async function () {
|
|
|
31
19
|
name: 'Vue app',
|
|
32
20
|
plugins: [],
|
|
33
21
|
router: {},
|
|
34
|
-
serverMiddleware: [],
|
|
35
22
|
userScalable: true
|
|
36
23
|
};
|
|
37
|
-
let localConfig;
|
|
38
|
-
try {
|
|
39
|
-
const jitiInstance = jiti(this.options.rootDir, {
|
|
40
|
-
esmResolve: true,
|
|
41
|
-
interopDefault: true,
|
|
42
|
-
transform: jitiBabelTransform
|
|
43
|
-
});
|
|
44
|
-
localConfig = jitiInstance('./nuxt.config.js');
|
|
45
|
-
} catch (error) {
|
|
46
|
-
if (error.message.startsWith("Cannot find module './nuxt.config.js'\n")) {
|
|
47
|
-
localConfig = {};
|
|
48
|
-
} else {
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
24
|
const projectConfig = {
|
|
53
25
|
...defaultConfig,
|
|
54
|
-
...
|
|
55
|
-
css: [...defaultConfig.css, ...(
|
|
26
|
+
...options,
|
|
27
|
+
css: [...defaultConfig.css, ...(options.css || [])]
|
|
56
28
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
name: 'viewport'
|
|
70
|
-
}, {
|
|
29
|
+
nuxt.options.watch.push('config.js');
|
|
30
|
+
nuxt.options.runtimeConfig.public.name = projectConfig.name;
|
|
31
|
+
nuxt.options.runtimeConfig.public.title = projectConfig.title;
|
|
32
|
+
if (process.env.BASIC_AUTH_USER && process.env.BASIC_AUTH_PASSWORD) {
|
|
33
|
+
nuxt.options.runtimeConfig.basicAuth = {
|
|
34
|
+
pairs: {
|
|
35
|
+
[process.env.BASIC_AUTH_USER]: process.env.BASIC_AUTH_PASSWORD
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
nuxt.options.app.head.link.push(...(projectConfig.head.link || []));
|
|
40
|
+
nuxt.options.app.head.meta.push({
|
|
71
41
|
content: projectConfig.name,
|
|
72
42
|
hid: 'description',
|
|
73
43
|
name: 'description'
|
|
74
44
|
});
|
|
45
|
+
if (!projectConfig.userScalable) {
|
|
46
|
+
const viewportMeta = nuxt.options.app.head.meta.find(meta => meta.name === 'viewport');
|
|
47
|
+
viewportMeta.content += ', user-scalable=0';
|
|
48
|
+
}
|
|
75
49
|
if (projectConfig.ogImage) {
|
|
76
|
-
|
|
50
|
+
nuxt.options.app.head.meta.push({
|
|
77
51
|
content: projectConfig.ogImage,
|
|
78
52
|
hid: 'og:image',
|
|
79
53
|
name: 'og:image'
|
|
80
54
|
});
|
|
81
55
|
}
|
|
82
56
|
if (projectConfig.webApp) {
|
|
83
|
-
|
|
57
|
+
nuxt.options.app.head.meta.push({
|
|
84
58
|
content: 'yes',
|
|
85
59
|
name: 'apple-mobile-web-app-capable'
|
|
86
60
|
});
|
|
87
61
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.options.serverMiddleware.push(...projectConfig.serverMiddleware);
|
|
93
|
-
this.options.components = true;
|
|
94
|
-
Object.assign(this.options.router, {
|
|
62
|
+
nuxt.options.app.head.htmlAttrs = projectConfig.htmlAttrs;
|
|
63
|
+
nuxt.options.app.head.bodyAttrs = projectConfig.bodyAttrs;
|
|
64
|
+
nuxt.options.css.push(...projectConfig.css);
|
|
65
|
+
Object.assign(nuxt.options.router.options, {
|
|
95
66
|
linkActiveClass: 'active',
|
|
96
67
|
routeNameSplitter: '.',
|
|
97
|
-
...
|
|
68
|
+
...projectConfig.router
|
|
98
69
|
});
|
|
99
|
-
|
|
100
|
-
Object.assign(this.options, (_projectConfig = projectConfig, omit((_defaultConfig$this$o = {
|
|
70
|
+
Object.assign(nuxt.options, omit(Object.keys({
|
|
101
71
|
...defaultConfig,
|
|
102
|
-
...
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
enabled:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}], babelModule, dotenvModule, [packageName`@nuxtjs/eslint-module`, {
|
|
72
|
+
...nuxt.options
|
|
73
|
+
}))(projectConfig));
|
|
74
|
+
const modules = [[packageName`nuxt-basic-authentication-module`, {
|
|
75
|
+
enabled: nuxt.options.runtimeConfig.basicAuth !== undefined
|
|
76
|
+
}], [packageName`@nuxtjs/eslint-module`, {
|
|
77
|
+
cache: false,
|
|
109
78
|
failOnWarning: true,
|
|
110
|
-
fix: true
|
|
79
|
+
fix: true,
|
|
80
|
+
lintOnStart: false
|
|
111
81
|
}], [packageName`@nuxtjs/stylelint-module`, {
|
|
112
82
|
allowEmptyInput: true,
|
|
113
83
|
failOnWarning: true,
|
|
114
|
-
fix: true
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
84
|
+
fix: true,
|
|
85
|
+
lintOnStart: false
|
|
86
|
+
}], i18nModule, expressModule, svgModule, localeLinkModule, ...(projectConfig.modules || [])];
|
|
87
|
+
for (let module of modules) {
|
|
88
|
+
module = [].concat(module);
|
|
89
|
+
await installModule(module[0], module[1]);
|
|
90
|
+
}
|
|
91
|
+
addTemplate({
|
|
119
92
|
fileName: P.join('project', 'project-config.js'),
|
|
120
93
|
options: projectConfig,
|
|
121
94
|
src: _require.resolve('./project-config.js.template')
|
|
122
95
|
});
|
|
123
|
-
|
|
124
|
-
|
|
96
|
+
for (const plugin of projectConfig.plugins) {
|
|
97
|
+
addPlugin(plugin, {
|
|
98
|
+
append: true
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import jitiBabelTransform from '@dword-design/jiti-babel-transform';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import mountFiles from 'express-mount-files';
|
|
4
|
+
import { fromNodeMiddleware } from 'h3';
|
|
5
|
+
import jiti from 'jiti';
|
|
6
|
+
import P from 'path';
|
|
7
|
+
import options from '#express/options.js';
|
|
8
|
+
const jitiOptions = {
|
|
9
|
+
esmResolve: true,
|
|
10
|
+
interopDefault: true,
|
|
11
|
+
transform: jitiBabelTransform
|
|
12
|
+
};
|
|
13
|
+
const jitiInstance = jiti(options.srcDir, jitiOptions);
|
|
14
|
+
let app = express().use(express.json()).use(express.urlencoded({
|
|
15
|
+
extended: false
|
|
16
|
+
}));
|
|
17
|
+
try {
|
|
18
|
+
const setupExpress = jitiInstance('./setup-express');
|
|
19
|
+
app = setupExpress(app);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (!error.message.startsWith("Cannot find module './setup-express'")) {
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
app.use('/api', mountFiles(P.resolve(options.srcDir, 'api'), {
|
|
26
|
+
jitiOptions,
|
|
27
|
+
paramChar: '_'
|
|
28
|
+
}));
|
|
29
|
+
export default fromNodeMiddleware(app);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { addServerHandler, addTemplate, createResolver } from '@nuxt/kit';
|
|
2
|
+
import nuxtAliasPath from 'nuxt-alias-path';
|
|
3
|
+
import P from 'path';
|
|
4
|
+
const resolver = createResolver(import.meta.url);
|
|
5
|
+
const moduleName = 'express';
|
|
6
|
+
export default ((options, nuxt) => {
|
|
7
|
+
addTemplate({
|
|
8
|
+
filename: P.join(moduleName, 'options.js'),
|
|
9
|
+
getContents: () => `export default ${JSON.stringify({
|
|
10
|
+
srcDir: nuxt.options.srcDir
|
|
11
|
+
}, undefined, 2)}`,
|
|
12
|
+
write: true
|
|
13
|
+
});
|
|
14
|
+
nuxt.options.alias[`#${moduleName}`] = nuxtAliasPath(moduleName, nuxt);
|
|
15
|
+
addServerHandler({
|
|
16
|
+
handler: resolver.resolve('./handler')
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -1,79 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import traverse from '@babel/traverse';
|
|
3
|
-
import map from "@dword-design/functions/dist/map.js";
|
|
4
|
-
import some from "@dword-design/functions/dist/some.js";
|
|
5
|
-
import uniq from "@dword-design/functions/dist/uniq.js";
|
|
1
|
+
import { installModule } from '@nuxt/kit';
|
|
6
2
|
import packageName from 'depcheck-package-name';
|
|
7
|
-
import fs from 'fs-extra';
|
|
8
3
|
import { globby } from 'globby';
|
|
9
4
|
import P from 'path';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const layout = (await fs.exists(P.join('layouts', layoutFile))) ? vueTemplateCompiler.parseComponent(await fs.readFile(P.join('layouts', layoutFile), 'utf8')) : {};
|
|
21
|
-
if ((_layout$script = layout.script) !== null && _layout$script !== void 0 && _layout$script.content) {
|
|
22
|
-
var _layout$script2;
|
|
23
|
-
const ast = await babel.parse((_layout$script2 = layout.script) === null || _layout$script2 === void 0 ? void 0 : _layout$script2.content, {
|
|
24
|
-
filename: 'index.js'
|
|
25
|
-
});
|
|
26
|
-
let valid = false;
|
|
27
|
-
traverse.default(ast, {
|
|
28
|
-
ExportDefaultDeclaration: path => {
|
|
29
|
-
var _path$node$declaratio;
|
|
30
|
-
if (_path$node$declaratio = path.node.declaration.properties, some(property => {
|
|
31
|
-
var _property$key, _property$body$body$, _property$body$body$2, _property$body$body$3;
|
|
32
|
-
return property.type === 'ObjectMethod' && ((_property$key = property.key) === null || _property$key === void 0 ? void 0 : _property$key.name) === 'head' && property.body.body.length === 1 && property.body.body[0].type === 'ReturnStatement' && property.body.body[0].argument.type === 'CallExpression' && property.body.body[0].argument.callee.type === 'MemberExpression' && property.body.body[0].argument.callee.object.type === 'ThisExpression' && ((_property$body$body$ = property.body.body[0].argument.callee.property) === null || _property$body$body$ === void 0 ? void 0 : _property$body$body$.name) === '$nuxtI18nHead' && property.body.body[0].argument.arguments.length === 1 && property.body.body[0].argument.arguments[0].type === 'ObjectExpression' && property.body.body[0].argument.arguments[0].properties.length === 1 && ((_property$body$body$2 = property.body.body[0].argument.arguments[0].properties[0].key) === null || _property$body$body$2 === void 0 ? void 0 : _property$body$body$2.name) === 'addSeoAttributes' && ((_property$body$body$3 = property.body.body[0].argument.arguments[0].properties[0].value) === null || _property$body$body$3 === void 0 ? void 0 : _property$body$body$3.value) === true;
|
|
33
|
-
})(_path$node$declaratio)) {
|
|
34
|
-
valid = true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
if (valid) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
throw new MissingNuxtI18nHeadError(layoutFile);
|
|
43
|
-
};
|
|
44
|
-
return Promise.all((_layoutFiles = layoutFiles, map(checkLayoutFile)(_layoutFiles)));
|
|
45
|
-
};
|
|
46
|
-
export default async function () {
|
|
47
|
-
const localeFiles = await globby('*.json', {
|
|
48
|
-
cwd: P.join(this.options.srcDir, 'i18n')
|
|
49
|
-
});
|
|
50
|
-
if (localeFiles.length > 0) {
|
|
51
|
-
var _localeFiles;
|
|
52
|
-
await checkNuxtI18nHead();
|
|
53
|
-
await this.addModule([packageName`@nuxtjs/i18n`, {
|
|
54
|
-
detectBrowserLanguage: localeFiles.length === 1 ? false : {
|
|
55
|
-
fallbackLocale: 'en',
|
|
5
|
+
export default (async (options, nuxt) => {
|
|
6
|
+
const locales = (await globby('*.json', {
|
|
7
|
+
cwd: P.join(nuxt.options.srcDir, 'i18n')
|
|
8
|
+
})).map(filename => P.basename(filename, '.json'));
|
|
9
|
+
const defaultLocale = locales.includes('en') ? 'en' : locales[0];
|
|
10
|
+
if (locales.length > 0) {
|
|
11
|
+
await installModule(packageName`@nuxtjs/i18n`, {
|
|
12
|
+
defaultLocale,
|
|
13
|
+
detectBrowserLanguage: locales.length === 1 ? false : {
|
|
14
|
+
fallbackLocale: defaultLocale,
|
|
56
15
|
redirectOn: 'no prefix',
|
|
57
16
|
useCookie: false
|
|
58
17
|
},
|
|
59
|
-
langDir: 'i18n
|
|
18
|
+
langDir: 'i18n',
|
|
60
19
|
lazy: true,
|
|
61
|
-
locales:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
})(_localeFiles)),
|
|
69
|
-
seo: localeFiles.length > 1,
|
|
70
|
-
strategy: localeFiles.length === 1 ? 'no_prefix' : 'prefix',
|
|
71
|
-
...(localeFiles.length === 1 && {
|
|
72
|
-
defaultLocale: P.basename(localeFiles[0], '.json')
|
|
73
|
-
}),
|
|
20
|
+
locales: locales.map(locale => ({
|
|
21
|
+
code: locale,
|
|
22
|
+
file: `${locale}.json`,
|
|
23
|
+
iso: locale
|
|
24
|
+
})),
|
|
25
|
+
strategy: `${locales.length === 1 ? 'no_' : ''}prefix`,
|
|
74
26
|
...(process.env.BASE_URL && {
|
|
75
27
|
baseUrl: process.env.BASE_URL
|
|
76
28
|
})
|
|
77
|
-
}
|
|
29
|
+
});
|
|
78
30
|
}
|
|
79
|
-
}
|
|
31
|
+
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import nuxtPushPlugins from 'nuxt-push-plugins';
|
|
1
|
+
import { addPlugin, addTemplate, createResolver } from '@nuxt/kit';
|
|
3
2
|
import P from 'path';
|
|
4
|
-
const
|
|
5
|
-
export default
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
src:
|
|
3
|
+
const resolver = createResolver(import.meta.url);
|
|
4
|
+
export default (() => {
|
|
5
|
+
addTemplate({
|
|
6
|
+
filename: P.join('nuxt-locale-link', 'component.vue'),
|
|
7
|
+
src: resolver.resolve('./component.vue'),
|
|
8
|
+
write: true
|
|
9
9
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
src:
|
|
10
|
+
addPlugin({
|
|
11
|
+
filename: P.join('nuxt-locale-link', 'plugin.js'),
|
|
12
|
+
src: resolver.resolve('./plugin')
|
|
13
|
+
}, {
|
|
14
|
+
append: true
|
|
13
15
|
});
|
|
14
|
-
}
|
|
16
|
+
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { defineNuxtPlugin } from '#imports';
|
|
2
|
+
import Component from "./component.vue";
|
|
3
|
+
export default defineNuxtPlugin(nuxtApp => nuxtApp.vueApp.component('NuxtLocaleLink', Component));
|
package/dist/prepublish-only.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import { execa } from 'execa';
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
|
-
import {
|
|
4
|
-
import getNuxtConfig from "./get-nuxt-config.js";
|
|
3
|
+
import { createRequire } from 'module';
|
|
5
4
|
import lint from "./lint.js";
|
|
5
|
+
const _require = createRequire(import.meta.url);
|
|
6
|
+
const nuxtWrapper = _require.resolve('./nuxt-wrapper.js');
|
|
6
7
|
export default (async (options = {}) => {
|
|
8
|
+
options = {
|
|
9
|
+
log: process.env.NODE_ENV !== 'test',
|
|
10
|
+
...options
|
|
11
|
+
};
|
|
7
12
|
await lint();
|
|
8
|
-
|
|
9
|
-
...
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
await execa(nuxtWrapper, ['build'], {
|
|
14
|
+
...(options.log ? {
|
|
15
|
+
stdio: 'inherit'
|
|
16
|
+
} : {}),
|
|
17
|
+
...(process.env.NODE_ENV === 'test' ? {
|
|
18
|
+
env: {
|
|
19
|
+
NUXT_TELEMETRY_DISABLED: 1
|
|
20
|
+
}
|
|
21
|
+
} : {})
|
|
14
22
|
});
|
|
15
|
-
await new Builder(nuxt).build();
|
|
16
23
|
if (await fs.exists('model')) {
|
|
17
24
|
await fs.remove('dist');
|
|
18
|
-
await execa('babel', ['--out-dir', 'dist', '--copy-files', '--no-copy-ignored', '--ignore', '**/*.spec.js', 'model'], {
|
|
19
|
-
stdio:
|
|
20
|
-
});
|
|
25
|
+
await execa('babel', ['--out-dir', 'dist', '--copy-files', '--no-copy-ignored', '--ignore', '**/*.spec.js', 'model'], ...(options.log ? [{
|
|
26
|
+
stdio: 'inherit'
|
|
27
|
+
}] : []));
|
|
21
28
|
}
|
|
22
29
|
});
|
package/dist/start.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
rootDir: options.rootDir
|
|
14
|
-
});
|
|
15
|
-
await nuxt.listen();
|
|
16
|
-
return nuxt;
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
const _require = createRequire(import.meta.url);
|
|
4
|
+
const nuxtWrapper = _require.resolve('./nuxt-wrapper.js');
|
|
5
|
+
export default ((options = {}) => {
|
|
6
|
+
options = {
|
|
7
|
+
log: process.env.NODE_ENV !== 'test',
|
|
8
|
+
...options
|
|
9
|
+
};
|
|
10
|
+
return execa(nuxtWrapper, ['start'], ...(options.log ? [{
|
|
11
|
+
stdio: 'inherit'
|
|
12
|
+
}] : []));
|
|
17
13
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dword-design/base-config-nuxt",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"repository": "dword-design/base-config-nuxt",
|
|
5
5
|
"funding": "https://github.com/sponsors/dword-design",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,22 +19,18 @@
|
|
|
19
19
|
"lint": "base lint",
|
|
20
20
|
"prepare": "base prepare",
|
|
21
21
|
"prepublishOnly": "base prepublishOnly",
|
|
22
|
-
"test": "base test"
|
|
23
|
-
"test:raw": "base test:raw"
|
|
22
|
+
"test": "base test"
|
|
24
23
|
},
|
|
25
24
|
"dependencies": {
|
|
26
|
-
"@babel/core": "^7.16.0",
|
|
27
|
-
"@babel/traverse": "^7.16.3",
|
|
28
25
|
"@dword-design/depcheck-parser-sass": "^3.0.0",
|
|
29
26
|
"@dword-design/dotenv-json-extended": "^2.0.0",
|
|
30
|
-
"@dword-design/eslint-config": "^3.0.1",
|
|
31
27
|
"@dword-design/functions": "^4.0.0",
|
|
32
28
|
"@dword-design/jiti-babel-transform": "^1.0.11",
|
|
33
29
|
"@dword-design/stylelint-config": "^2.0.0",
|
|
34
|
-
"@
|
|
35
|
-
"@nuxtjs/eslint-module": "^
|
|
36
|
-
"@nuxtjs/i18n": "
|
|
37
|
-
"@nuxtjs/stylelint-module": "^
|
|
30
|
+
"@nuxt/kit": "^3.2.3",
|
|
31
|
+
"@nuxtjs/eslint-module": "^4.1.0",
|
|
32
|
+
"@nuxtjs/i18n": "npm:@dword-design/nuxt-i18n",
|
|
33
|
+
"@nuxtjs/stylelint-module": "^5.0.1",
|
|
38
34
|
"depcheck-package-name": "^3.0.0",
|
|
39
35
|
"depcheck-parser-vue": "^3.0.1",
|
|
40
36
|
"execa": "^6.1.0",
|
|
@@ -43,35 +39,33 @@
|
|
|
43
39
|
"fs-extra": "^11.1.0",
|
|
44
40
|
"globby": "^13.1.3",
|
|
45
41
|
"jiti": "^1.18.2",
|
|
46
|
-
"nuxt": "
|
|
47
|
-
"nuxt-
|
|
48
|
-
"nuxt-basic-
|
|
49
|
-
"
|
|
50
|
-
"nuxt-svg-loader": "^1.2.0",
|
|
51
|
-
"promise-sequential": "^1.1.1",
|
|
52
|
-
"raw-loader": "^4.0.1",
|
|
53
|
-
"sass": "^1.34.0",
|
|
54
|
-
"sass-loader": "^10.0.0",
|
|
42
|
+
"nuxt": "^3.2.3",
|
|
43
|
+
"nuxt-alias-path": "^1.0.0",
|
|
44
|
+
"nuxt-basic-authentication-module": "^0.2.1",
|
|
45
|
+
"output-files": "^2.0.0",
|
|
55
46
|
"stylelint": "^13.6.0",
|
|
56
|
-
"
|
|
57
|
-
"vue-template-compiler": "^2.6.14"
|
|
47
|
+
"vite-svg-loader": "^4.0.0"
|
|
58
48
|
},
|
|
59
49
|
"devDependencies": {
|
|
60
|
-
"@dword-design/base": "^
|
|
50
|
+
"@dword-design/base": "^10.0.0",
|
|
61
51
|
"@dword-design/puppeteer": "^6.0.0",
|
|
62
52
|
"@dword-design/tester": "^2.0.9",
|
|
63
|
-
"@dword-design/tester-plugin-env": "^2.0.8",
|
|
64
53
|
"@dword-design/tester-plugin-puppeteer": "^2.1.19",
|
|
65
54
|
"@dword-design/tester-plugin-tmp-dir": "^2.1.3",
|
|
66
|
-
"@
|
|
55
|
+
"@funken-studio/sitemap-nuxt-3": "^4.0.4",
|
|
67
56
|
"axios": "^0.22.0",
|
|
68
57
|
"depcheck": "^1.4.2",
|
|
69
|
-
"
|
|
58
|
+
"nuxt-dev-ready": "^2.0.0",
|
|
59
|
+
"p-all": "^5.0.0",
|
|
70
60
|
"port-ready": "^0.1.0",
|
|
61
|
+
"tree-kill-promise": "^3.0.1",
|
|
71
62
|
"xml-formatter": "^3.2.0"
|
|
72
63
|
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"h3": "*"
|
|
66
|
+
},
|
|
73
67
|
"engines": {
|
|
74
|
-
"node": ">=
|
|
68
|
+
"node": ">=16"
|
|
75
69
|
},
|
|
76
70
|
"publishConfig": {
|
|
77
71
|
"access": "public"
|
package/dist/get-nuxt-config.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import endent from "@dword-design/functions/dist/endent.js";
|
|
2
|
-
import P from 'path';
|
|
3
|
-
export default class extends Error {
|
|
4
|
-
constructor(layoutFile) {
|
|
5
|
-
super(endent`
|
|
6
|
-
You have to implement $nuxtI18nHead in ${P.join('layouts', layoutFile)} like this to make sure that i18n metadata are generated:
|
|
7
|
-
|
|
8
|
-
<script>
|
|
9
|
-
export default {
|
|
10
|
-
head () {
|
|
11
|
-
return this.$nuxtI18nHead({ addSeoAttributes: true })
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
</script>
|
|
15
|
-
`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import jitiBabelTransform from '@dword-design/jiti-babel-transform';
|
|
2
|
-
import express from 'express';
|
|
3
|
-
import mountFiles from 'express-mount-files';
|
|
4
|
-
import P from 'path';
|
|
5
|
-
export default async function (options) {
|
|
6
|
-
// Make sure that we do not register the server middleware
|
|
7
|
-
// on build because processes like express-mysql-session do
|
|
8
|
-
// not get closed
|
|
9
|
-
// https://github.com/nuxt/nuxt.js/blob/2ec62617ced873fef97c73a6d7aa1271911ccfd5/packages/core/src/nuxt.js#L56
|
|
10
|
-
if (this.options.server !== false) {
|
|
11
|
-
var _options$getExpress;
|
|
12
|
-
const app = (await ((_options$getExpress = options.getExpress) === null || _options$getExpress === void 0 ? void 0 : _options$getExpress.call(options))) || express();
|
|
13
|
-
app.use(mountFiles(P.join(this.options.srcDir, 'api'), {
|
|
14
|
-
jitiOptions: {
|
|
15
|
-
esmResolve: true,
|
|
16
|
-
interopDefault: true,
|
|
17
|
-
transform: jitiBabelTransform
|
|
18
|
-
},
|
|
19
|
-
paramChar: '_'
|
|
20
|
-
}));
|
|
21
|
-
this.addServerMiddleware({
|
|
22
|
-
handler: app,
|
|
23
|
-
path: '/api'
|
|
24
|
-
});
|
|
25
|
-
this.options.watch.push(P.join(this.options.srcDir, 'api'));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
File without changes
|