create-nexora-next 0.3.6 → 0.3.7
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/README.md +45 -45
- package/package.json +46 -46
- package/src/index.js +266 -266
- package/src/steps/01-create-next-app.js +18 -18
- package/src/steps/02-shadcn.js +38 -38
- package/src/steps/03-base-files.js +109 -109
- package/src/steps/04-providers.js +51 -51
- package/src/steps/05-i18n.js +41 -41
- package/src/steps/06-auth.js +30 -30
- package/src/steps/07-proxy.js +16 -16
- package/src/steps/08-install-deps.js +82 -82
- package/src/steps/09-husky.js +58 -58
- package/src/steps/10-axios.js +14 -14
- package/src/steps/11-patch-pkg.js +21 -21
- package/src/templates/files.js +908 -908
- package/src/utils/runner.js +49 -49
- package/src/utils/safe-step.js +42 -42
- package/src/utils/writer.js +37 -37
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import fs from 'fs'
|
|
3
|
-
import { writeFile, mkdir } from '../utils/writer.js'
|
|
4
|
-
import { safeStep } from '../utils/safe-step.js'
|
|
5
|
-
import {
|
|
6
|
-
envLocal,
|
|
7
|
-
prettierRc,
|
|
8
|
-
fontsTs,
|
|
9
|
-
utilsTs,
|
|
10
|
-
utilsWithAxiosTs,
|
|
11
|
-
constantsTs,
|
|
12
|
-
seoTs,
|
|
13
|
-
seoWithLocaleTs,
|
|
14
|
-
sileoUiTsx,
|
|
15
|
-
sileoProviderTsx,
|
|
16
|
-
nuqsAdapterTsx,
|
|
17
|
-
rootLayoutI18nTs,
|
|
18
|
-
rootLayoutTs,
|
|
19
|
-
localeLayoutTs,
|
|
20
|
-
eslintConfigMjs,
|
|
21
|
-
sitemapTs,
|
|
22
|
-
} from '../templates/files.js'
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {string} targetDir
|
|
26
|
-
* @param {{ i18n: boolean, axios: boolean, query: boolean }} opts
|
|
27
|
-
*/
|
|
28
|
-
export async function stepWriteBaseFiles(targetDir, opts) {
|
|
29
|
-
await safeStep('Writing base config files', () => {
|
|
30
|
-
const p = (...parts) => path.join(targetDir, ...parts)
|
|
31
|
-
|
|
32
|
-
// .env.local
|
|
33
|
-
writeFile(p('.env.local'), envLocal)
|
|
34
|
-
|
|
35
|
-
// .prettierrc
|
|
36
|
-
writeFile(p('.prettierrc'), prettierRc)
|
|
37
|
-
|
|
38
|
-
// src/lib/fonts.ts
|
|
39
|
-
writeFile(p('src', 'lib', 'fonts.ts'), fontsTs)
|
|
40
|
-
|
|
41
|
-
// src/lib/utils/index.ts
|
|
42
|
-
writeFile(
|
|
43
|
-
p('src', 'lib', 'utils', 'index.ts'),
|
|
44
|
-
opts.axios ? utilsWithAxiosTs : utilsTs,
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
// src/constants/index.ts
|
|
48
|
-
writeFile(p('src', 'constants', 'index.ts'), constantsTs(opts))
|
|
49
|
-
|
|
50
|
-
// src/lib/seo/index.ts
|
|
51
|
-
writeFile(
|
|
52
|
-
p('src', 'lib', 'seo', 'index.ts'),
|
|
53
|
-
opts.i18n ? seoWithLocaleTs : seoTs,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
// src/components/ui/sileo.tsx
|
|
57
|
-
writeFile(p('src', 'components', 'ui', 'sileo.tsx'), sileoUiTsx)
|
|
58
|
-
|
|
59
|
-
// src/components/providers/sileo.provider.tsx
|
|
60
|
-
writeFile(p('src', 'components', 'providers', 'sileo.provider.tsx'), sileoProviderTsx)
|
|
61
|
-
|
|
62
|
-
// src/components/adapters/nuqs.adapter.tsx
|
|
63
|
-
writeFile(p('src', 'components', 'adapters', 'nuqs.adapter.tsx'), nuqsAdapterTsx)
|
|
64
|
-
|
|
65
|
-
// Empty structural folders
|
|
66
|
-
const emptyDirs = [
|
|
67
|
-
['src', 'hooks'],
|
|
68
|
-
['src', 'components', 'atoms'],
|
|
69
|
-
['src', 'components', 'molecules'],
|
|
70
|
-
['src', 'components', 'organisms'],
|
|
71
|
-
['src', 'components', 'primitives'],
|
|
72
|
-
]
|
|
73
|
-
for (const parts of emptyDirs) {
|
|
74
|
-
mkdir(p(...parts))
|
|
75
|
-
writeFile(p(...parts, 'index.ts'), `// ${parts[parts.length - 1]}\n`)
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
// ── Layouts ────────────────────────────────────────────────────────────────
|
|
80
|
-
await safeStep('Setting up app layouts', () => {
|
|
81
|
-
const p = (...parts) => path.join(targetDir, ...parts)
|
|
82
|
-
|
|
83
|
-
if (opts.i18n) {
|
|
84
|
-
// Replace root layout with passthrough shell
|
|
85
|
-
writeFile(p('src', 'app', 'layout.tsx'), rootLayoutI18nTs)
|
|
86
|
-
|
|
87
|
-
// Remove the default src/app/page.tsx (locale takes over routing)
|
|
88
|
-
const defaultPage = p('src', 'app', 'page.tsx')
|
|
89
|
-
if (fs.existsSync(defaultPage)) fs.unlinkSync(defaultPage)
|
|
90
|
-
|
|
91
|
-
// Create src/app/[locale]/layout.tsx
|
|
92
|
-
writeFile(p('src', 'app', '[locale]', 'layout.tsx'), localeLayoutTs)
|
|
93
|
-
} else {
|
|
94
|
-
// Standard root layout wiring up Providers
|
|
95
|
-
writeFile(p('src', 'app', 'layout.tsx'), rootLayoutTs)
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
// ── ESLint config ──────────────────────────────────────────────────────────
|
|
100
|
-
await safeStep('Replacing ESLint config', () => {
|
|
101
|
-
const p = (...parts) => path.join(targetDir, ...parts)
|
|
102
|
-
writeFile(p('eslint.config.mjs'), eslintConfigMjs(opts))
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
// ── Sitemap ────────────────────────────────────────────────────────────────
|
|
106
|
-
await safeStep('Writing sitemap', () => {
|
|
107
|
-
const p = (...parts) => path.join(targetDir, ...parts)
|
|
108
|
-
writeFile(p('src', 'app', 'sitemap.ts'), sitemapTs)
|
|
109
|
-
})
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import { writeFile, mkdir } from '../utils/writer.js'
|
|
4
|
+
import { safeStep } from '../utils/safe-step.js'
|
|
5
|
+
import {
|
|
6
|
+
envLocal,
|
|
7
|
+
prettierRc,
|
|
8
|
+
fontsTs,
|
|
9
|
+
utilsTs,
|
|
10
|
+
utilsWithAxiosTs,
|
|
11
|
+
constantsTs,
|
|
12
|
+
seoTs,
|
|
13
|
+
seoWithLocaleTs,
|
|
14
|
+
sileoUiTsx,
|
|
15
|
+
sileoProviderTsx,
|
|
16
|
+
nuqsAdapterTsx,
|
|
17
|
+
rootLayoutI18nTs,
|
|
18
|
+
rootLayoutTs,
|
|
19
|
+
localeLayoutTs,
|
|
20
|
+
eslintConfigMjs,
|
|
21
|
+
sitemapTs,
|
|
22
|
+
} from '../templates/files.js'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {string} targetDir
|
|
26
|
+
* @param {{ i18n: boolean, axios: boolean, query: boolean }} opts
|
|
27
|
+
*/
|
|
28
|
+
export async function stepWriteBaseFiles(targetDir, opts) {
|
|
29
|
+
await safeStep('Writing base config files', () => {
|
|
30
|
+
const p = (...parts) => path.join(targetDir, ...parts)
|
|
31
|
+
|
|
32
|
+
// .env.local
|
|
33
|
+
writeFile(p('.env.local'), envLocal)
|
|
34
|
+
|
|
35
|
+
// .prettierrc
|
|
36
|
+
writeFile(p('.prettierrc'), prettierRc)
|
|
37
|
+
|
|
38
|
+
// src/lib/fonts.ts
|
|
39
|
+
writeFile(p('src', 'lib', 'fonts.ts'), fontsTs)
|
|
40
|
+
|
|
41
|
+
// src/lib/utils/index.ts
|
|
42
|
+
writeFile(
|
|
43
|
+
p('src', 'lib', 'utils', 'index.ts'),
|
|
44
|
+
opts.axios ? utilsWithAxiosTs : utilsTs,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
// src/constants/index.ts
|
|
48
|
+
writeFile(p('src', 'constants', 'index.ts'), constantsTs(opts))
|
|
49
|
+
|
|
50
|
+
// src/lib/seo/index.ts
|
|
51
|
+
writeFile(
|
|
52
|
+
p('src', 'lib', 'seo', 'index.ts'),
|
|
53
|
+
opts.i18n ? seoWithLocaleTs : seoTs,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
// src/components/ui/sileo.tsx
|
|
57
|
+
writeFile(p('src', 'components', 'ui', 'sileo.tsx'), sileoUiTsx)
|
|
58
|
+
|
|
59
|
+
// src/components/providers/sileo.provider.tsx
|
|
60
|
+
writeFile(p('src', 'components', 'providers', 'sileo.provider.tsx'), sileoProviderTsx)
|
|
61
|
+
|
|
62
|
+
// src/components/adapters/nuqs.adapter.tsx
|
|
63
|
+
writeFile(p('src', 'components', 'adapters', 'nuqs.adapter.tsx'), nuqsAdapterTsx)
|
|
64
|
+
|
|
65
|
+
// Empty structural folders
|
|
66
|
+
const emptyDirs = [
|
|
67
|
+
['src', 'hooks'],
|
|
68
|
+
['src', 'components', 'atoms'],
|
|
69
|
+
['src', 'components', 'molecules'],
|
|
70
|
+
['src', 'components', 'organisms'],
|
|
71
|
+
['src', 'components', 'primitives'],
|
|
72
|
+
]
|
|
73
|
+
for (const parts of emptyDirs) {
|
|
74
|
+
mkdir(p(...parts))
|
|
75
|
+
writeFile(p(...parts, 'index.ts'), `// ${parts[parts.length - 1]}\n`)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// ── Layouts ────────────────────────────────────────────────────────────────
|
|
80
|
+
await safeStep('Setting up app layouts', () => {
|
|
81
|
+
const p = (...parts) => path.join(targetDir, ...parts)
|
|
82
|
+
|
|
83
|
+
if (opts.i18n) {
|
|
84
|
+
// Replace root layout with passthrough shell
|
|
85
|
+
writeFile(p('src', 'app', 'layout.tsx'), rootLayoutI18nTs)
|
|
86
|
+
|
|
87
|
+
// Remove the default src/app/page.tsx (locale takes over routing)
|
|
88
|
+
const defaultPage = p('src', 'app', 'page.tsx')
|
|
89
|
+
if (fs.existsSync(defaultPage)) fs.unlinkSync(defaultPage)
|
|
90
|
+
|
|
91
|
+
// Create src/app/[locale]/layout.tsx
|
|
92
|
+
writeFile(p('src', 'app', '[locale]', 'layout.tsx'), localeLayoutTs)
|
|
93
|
+
} else {
|
|
94
|
+
// Standard root layout wiring up Providers
|
|
95
|
+
writeFile(p('src', 'app', 'layout.tsx'), rootLayoutTs)
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// ── ESLint config ──────────────────────────────────────────────────────────
|
|
100
|
+
await safeStep('Replacing ESLint config', () => {
|
|
101
|
+
const p = (...parts) => path.join(targetDir, ...parts)
|
|
102
|
+
writeFile(p('eslint.config.mjs'), eslintConfigMjs(opts))
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// ── Sitemap ────────────────────────────────────────────────────────────────
|
|
106
|
+
await safeStep('Writing sitemap', () => {
|
|
107
|
+
const p = (...parts) => path.join(targetDir, ...parts)
|
|
108
|
+
writeFile(p('src', 'app', 'sitemap.ts'), sitemapTs)
|
|
109
|
+
})
|
|
110
110
|
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import {
|
|
3
|
-
localeProviderTsx,
|
|
4
|
-
providersIndexTsx,
|
|
5
|
-
queryClientProviderTsx,
|
|
6
|
-
themeProviderTsx,
|
|
7
|
-
tzProviderTsx,
|
|
8
|
-
} from "../templates/files.js";
|
|
9
|
-
import { safeStep } from "../utils/safe-step.js";
|
|
10
|
-
import { writeFile } from "../utils/writer.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {string} targetDir
|
|
14
|
-
* @param {{ i18n: boolean, theming: boolean, query: boolean }} opts
|
|
15
|
-
*/
|
|
16
|
-
export async function stepWriteProviders(targetDir, opts) {
|
|
17
|
-
await safeStep("Generating providers", () => {
|
|
18
|
-
const p = (...parts) => path.join(targetDir, ...parts);
|
|
19
|
-
|
|
20
|
-
// Dynamic providers/index.ts
|
|
21
|
-
writeFile(
|
|
22
|
-
p("src", "components", "providers", "index.tsx"),
|
|
23
|
-
providersIndexTsx(opts),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
if (opts.theming) {
|
|
27
|
-
writeFile(
|
|
28
|
-
p("src", "components", "providers", "theme.provider.tsx"),
|
|
29
|
-
themeProviderTsx,
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (opts.i18n) {
|
|
34
|
-
writeFile(
|
|
35
|
-
p("src", "components", "providers", "locale.provider.tsx"),
|
|
36
|
-
localeProviderTsx,
|
|
37
|
-
);
|
|
38
|
-
writeFile(
|
|
39
|
-
p("src", "components", "providers", "tz.provider.tsx"),
|
|
40
|
-
tzProviderTsx,
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (opts.query) {
|
|
45
|
-
writeFile(
|
|
46
|
-
p("src", "components", "providers", "query-client.provider.tsx"),
|
|
47
|
-
queryClientProviderTsx,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
1
|
+
import path from "path";
|
|
2
|
+
import {
|
|
3
|
+
localeProviderTsx,
|
|
4
|
+
providersIndexTsx,
|
|
5
|
+
queryClientProviderTsx,
|
|
6
|
+
themeProviderTsx,
|
|
7
|
+
tzProviderTsx,
|
|
8
|
+
} from "../templates/files.js";
|
|
9
|
+
import { safeStep } from "../utils/safe-step.js";
|
|
10
|
+
import { writeFile } from "../utils/writer.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} targetDir
|
|
14
|
+
* @param {{ i18n: boolean, theming: boolean, query: boolean }} opts
|
|
15
|
+
*/
|
|
16
|
+
export async function stepWriteProviders(targetDir, opts) {
|
|
17
|
+
await safeStep("Generating providers", () => {
|
|
18
|
+
const p = (...parts) => path.join(targetDir, ...parts);
|
|
19
|
+
|
|
20
|
+
// Dynamic providers/index.ts
|
|
21
|
+
writeFile(
|
|
22
|
+
p("src", "components", "providers", "index.tsx"),
|
|
23
|
+
providersIndexTsx(opts),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (opts.theming) {
|
|
27
|
+
writeFile(
|
|
28
|
+
p("src", "components", "providers", "theme.provider.tsx"),
|
|
29
|
+
themeProviderTsx,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (opts.i18n) {
|
|
34
|
+
writeFile(
|
|
35
|
+
p("src", "components", "providers", "locale.provider.tsx"),
|
|
36
|
+
localeProviderTsx,
|
|
37
|
+
);
|
|
38
|
+
writeFile(
|
|
39
|
+
p("src", "components", "providers", "tz.provider.tsx"),
|
|
40
|
+
tzProviderTsx,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (opts.query) {
|
|
45
|
+
writeFile(
|
|
46
|
+
p("src", "components", "providers", "query-client.provider.tsx"),
|
|
47
|
+
queryClientProviderTsx,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
package/src/steps/05-i18n.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import { writeFile } from '../utils/writer.js'
|
|
3
|
-
import { run, installCmd } from '../utils/runner.js'
|
|
4
|
-
import { safeStep } from '../utils/safe-step.js'
|
|
5
|
-
import {
|
|
6
|
-
i18nRoutingTs,
|
|
7
|
-
i18nRequestTs,
|
|
8
|
-
i18nNavigationTs,
|
|
9
|
-
nextIntlTs,
|
|
10
|
-
localesEnJson,
|
|
11
|
-
localPageTsx,
|
|
12
|
-
localeDateFormatsTs,
|
|
13
|
-
nextConfigI18nTs,
|
|
14
|
-
} from '../templates/files.js'
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {string} targetDir
|
|
18
|
-
* @param {'npm'|'pnpm'|'bun'|'yarn'} pm
|
|
19
|
-
* @param {{ reactCompiler: boolean }} opts
|
|
20
|
-
*/
|
|
21
|
-
export async function stepSetupI18n(targetDir, pm, opts) {
|
|
22
|
-
await safeStep('Installing next-intl', () => {
|
|
23
|
-
run(installCmd(pm, ['next-intl']), targetDir)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
await safeStep('Writing i18n files', () => {
|
|
27
|
-
const p = (...parts) => path.join(targetDir, ...parts)
|
|
28
|
-
|
|
29
|
-
writeFile(p('locales', 'en.json'), localesEnJson)
|
|
30
|
-
writeFile(p('src', 'i18n', 'routing.ts'), i18nRoutingTs)
|
|
31
|
-
writeFile(p('src', 'i18n', 'request.ts'), i18nRequestTs)
|
|
32
|
-
writeFile(p('src', 'i18n', 'navigation.ts'), i18nNavigationTs)
|
|
33
|
-
writeFile(p('next-intl.ts'), nextIntlTs)
|
|
34
|
-
writeFile(p('src', 'app', '[locale]', 'page.tsx'), localPageTsx)
|
|
35
|
-
writeFile(p('src', 'lib', 'utils', 'locale-date-formats.ts'), localeDateFormatsTs)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
await safeStep('Updating next.config.ts for next-intl', () => {
|
|
39
|
-
const p = (...parts) => path.join(targetDir, ...parts)
|
|
40
|
-
writeFile(p('next.config.ts'), nextConfigI18nTs(opts))
|
|
41
|
-
})
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { writeFile } from '../utils/writer.js'
|
|
3
|
+
import { run, installCmd } from '../utils/runner.js'
|
|
4
|
+
import { safeStep } from '../utils/safe-step.js'
|
|
5
|
+
import {
|
|
6
|
+
i18nRoutingTs,
|
|
7
|
+
i18nRequestTs,
|
|
8
|
+
i18nNavigationTs,
|
|
9
|
+
nextIntlTs,
|
|
10
|
+
localesEnJson,
|
|
11
|
+
localPageTsx,
|
|
12
|
+
localeDateFormatsTs,
|
|
13
|
+
nextConfigI18nTs,
|
|
14
|
+
} from '../templates/files.js'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} targetDir
|
|
18
|
+
* @param {'npm'|'pnpm'|'bun'|'yarn'} pm
|
|
19
|
+
* @param {{ reactCompiler: boolean }} opts
|
|
20
|
+
*/
|
|
21
|
+
export async function stepSetupI18n(targetDir, pm, opts) {
|
|
22
|
+
await safeStep('Installing next-intl', () => {
|
|
23
|
+
run(installCmd(pm, ['next-intl']), targetDir)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
await safeStep('Writing i18n files', () => {
|
|
27
|
+
const p = (...parts) => path.join(targetDir, ...parts)
|
|
28
|
+
|
|
29
|
+
writeFile(p('locales', 'en.json'), localesEnJson)
|
|
30
|
+
writeFile(p('src', 'i18n', 'routing.ts'), i18nRoutingTs)
|
|
31
|
+
writeFile(p('src', 'i18n', 'request.ts'), i18nRequestTs)
|
|
32
|
+
writeFile(p('src', 'i18n', 'navigation.ts'), i18nNavigationTs)
|
|
33
|
+
writeFile(p('next-intl.ts'), nextIntlTs)
|
|
34
|
+
writeFile(p('src', 'app', '[locale]', 'page.tsx'), localPageTsx)
|
|
35
|
+
writeFile(p('src', 'lib', 'utils', 'locale-date-formats.ts'), localeDateFormatsTs)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
await safeStep('Updating next.config.ts for next-intl', () => {
|
|
39
|
+
const p = (...parts) => path.join(targetDir, ...parts)
|
|
40
|
+
writeFile(p('next.config.ts'), nextConfigI18nTs(opts))
|
|
41
|
+
})
|
|
42
42
|
}
|
package/src/steps/06-auth.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import { writeFile } from '../utils/writer.js'
|
|
3
|
-
import { safeStep } from '../utils/safe-step.js'
|
|
4
|
-
import {
|
|
5
|
-
proxyLibTs,
|
|
6
|
-
proxyAuthTs,
|
|
7
|
-
validatorsAuthTs,
|
|
8
|
-
validatorsTs,
|
|
9
|
-
apisClientTs,
|
|
10
|
-
apisServerTs,
|
|
11
|
-
} from '../templates/files.js'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {string} targetDir
|
|
15
|
-
* @param {{ i18n: boolean, auth: boolean, axios: boolean }} opts
|
|
16
|
-
*/
|
|
17
|
-
export async function stepSetupAuth(targetDir, opts) {
|
|
18
|
-
await safeStep('Writing auth & proxy files', () => {
|
|
19
|
-
const p = (...parts) => path.join(targetDir, ...parts)
|
|
20
|
-
|
|
21
|
-
writeFile(p('src', 'lib', 'proxy', 'index.ts'), proxyLibTs)
|
|
22
|
-
|
|
23
|
-
if (opts.auth) {
|
|
24
|
-
writeFile(p('src', 'lib', 'proxy', 'auth.ts'), proxyAuthTs)
|
|
25
|
-
writeFile(p('src', 'lib', 'validators', 'index.ts'), validatorsTs)
|
|
26
|
-
writeFile(p('src', 'lib', 'validators', 'auth.ts'), validatorsAuthTs)
|
|
27
|
-
writeFile(p('src', 'apis', 'client', 'index.ts'), apisClientTs)
|
|
28
|
-
writeFile(p('src', 'apis', 'server', 'index.ts'), apisServerTs)
|
|
29
|
-
}
|
|
30
|
-
})
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { writeFile } from '../utils/writer.js'
|
|
3
|
+
import { safeStep } from '../utils/safe-step.js'
|
|
4
|
+
import {
|
|
5
|
+
proxyLibTs,
|
|
6
|
+
proxyAuthTs,
|
|
7
|
+
validatorsAuthTs,
|
|
8
|
+
validatorsTs,
|
|
9
|
+
apisClientTs,
|
|
10
|
+
apisServerTs,
|
|
11
|
+
} from '../templates/files.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} targetDir
|
|
15
|
+
* @param {{ i18n: boolean, auth: boolean, axios: boolean }} opts
|
|
16
|
+
*/
|
|
17
|
+
export async function stepSetupAuth(targetDir, opts) {
|
|
18
|
+
await safeStep('Writing auth & proxy files', () => {
|
|
19
|
+
const p = (...parts) => path.join(targetDir, ...parts)
|
|
20
|
+
|
|
21
|
+
writeFile(p('src', 'lib', 'proxy', 'index.ts'), proxyLibTs)
|
|
22
|
+
|
|
23
|
+
if (opts.auth) {
|
|
24
|
+
writeFile(p('src', 'lib', 'proxy', 'auth.ts'), proxyAuthTs)
|
|
25
|
+
writeFile(p('src', 'lib', 'validators', 'index.ts'), validatorsTs)
|
|
26
|
+
writeFile(p('src', 'lib', 'validators', 'auth.ts'), validatorsAuthTs)
|
|
27
|
+
writeFile(p('src', 'apis', 'client', 'index.ts'), apisClientTs)
|
|
28
|
+
writeFile(p('src', 'apis', 'server', 'index.ts'), apisServerTs)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
31
|
}
|
package/src/steps/07-proxy.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import { writeFile } from '../utils/writer.js'
|
|
3
|
-
import { safeStep } from '../utils/safe-step.js'
|
|
4
|
-
import { proxyTs } from '../templates/files.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {string} targetDir
|
|
8
|
-
* @param {{ i18n: boolean, auth: boolean }} opts
|
|
9
|
-
*/
|
|
10
|
-
export async function stepWriteProxy(targetDir, opts) {
|
|
11
|
-
if (!opts.i18n && !opts.auth) return
|
|
12
|
-
|
|
13
|
-
await safeStep('Writing Next.js middleware (proxy)', () => {
|
|
14
|
-
const p = (...parts) => path.join(targetDir, ...parts)
|
|
15
|
-
writeFile(p('src', 'proxy.ts'), proxyTs(opts))
|
|
16
|
-
})
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { writeFile } from '../utils/writer.js'
|
|
3
|
+
import { safeStep } from '../utils/safe-step.js'
|
|
4
|
+
import { proxyTs } from '../templates/files.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} targetDir
|
|
8
|
+
* @param {{ i18n: boolean, auth: boolean }} opts
|
|
9
|
+
*/
|
|
10
|
+
export async function stepWriteProxy(targetDir, opts) {
|
|
11
|
+
if (!opts.i18n && !opts.auth) return
|
|
12
|
+
|
|
13
|
+
await safeStep('Writing Next.js middleware (proxy)', () => {
|
|
14
|
+
const p = (...parts) => path.join(targetDir, ...parts)
|
|
15
|
+
writeFile(p('src', 'proxy.ts'), proxyTs(opts))
|
|
16
|
+
})
|
|
17
17
|
}
|