docus 1.0.7 → 3.0.0-beta.10

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 (135) hide show
  1. package/README.md +9 -22
  2. package/package.json +38 -63
  3. package/theme/app/router.options.ts +18 -0
  4. package/theme/assets/css/fonts.css +84 -0
  5. package/theme/assets/css/main.css +104 -0
  6. package/theme/components/app/Container.vue +25 -0
  7. package/theme/components/app/Footer.vue +40 -0
  8. package/theme/components/app/MobileNav.vue +85 -0
  9. package/theme/components/app/Navbar.vue +37 -0
  10. package/theme/components/app/NavbarLogo.vue +33 -0
  11. package/theme/components/app/Page.vue +7 -0
  12. package/theme/components/app/PoweredByDocus.vue +11 -0
  13. package/theme/components/content/Alert.vue +124 -0
  14. package/theme/components/content/BlockHero.vue +54 -0
  15. package/theme/components/content/ButtonLink.vue +45 -0
  16. package/theme/components/content/Card.vue +46 -0
  17. package/theme/components/content/CardGrid.vue +23 -0
  18. package/theme/components/content/CodeBlock.vue +47 -0
  19. package/theme/components/content/CodeGroup.vue +135 -0
  20. package/theme/components/content/CopyButton.vue +49 -0
  21. package/theme/components/content/List.vue +5 -0
  22. package/theme/components/content/NeedContribution.vue +23 -0
  23. package/theme/components/content/ReadMore.vue +25 -0
  24. package/theme/components/content/Sandbox.vue +102 -0
  25. package/theme/components/content/TabsHeader.vue +44 -0
  26. package/theme/components/content/Terminal.vue +64 -0
  27. package/theme/components/content/VideoPlayer.vue +115 -0
  28. package/theme/components/dev/Debug.vue +65 -0
  29. package/theme/components/docs/DocsAside.vue +21 -0
  30. package/theme/components/docs/DocsAsideTree.vue +104 -0
  31. package/theme/components/docs/DocsHero.vue +39 -0
  32. package/theme/components/docs/DocsPage.vue +21 -0
  33. package/theme/components/docs/DocsPageContent.vue +32 -0
  34. package/theme/components/docs/DocsToc.vue +77 -0
  35. package/theme/components/globals/Icon.vue +24 -0
  36. package/theme/components/globals/Logo.vue +3 -0
  37. package/theme/components/globals/NuxtImg.vue +45 -0
  38. package/theme/components/globals/SocialIcons.vue +45 -0
  39. package/theme/components/globals/ThemeSelect.vue +35 -0
  40. package/theme/components/icons/IconAlgolia.vue +8 -0
  41. package/theme/components/icons/IconArrowLeft.vue +10 -0
  42. package/theme/components/icons/IconArrowRight.vue +10 -0
  43. package/theme/components/icons/IconBadgeCheck.vue +14 -0
  44. package/theme/components/icons/IconCheck.vue +10 -0
  45. package/theme/components/icons/IconCheckCircle.vue +10 -0
  46. package/theme/components/icons/IconChevronRight.vue +12 -0
  47. package/theme/components/icons/IconClipboardCheck.vue +14 -0
  48. package/theme/components/icons/IconClipboardCopy.vue +14 -0
  49. package/theme/components/icons/IconCodeSandbox.vue +8 -0
  50. package/theme/components/icons/IconCopy.vue +17 -0
  51. package/theme/components/icons/IconDots.vue +10 -0
  52. package/theme/components/icons/IconEdit.vue +18 -0
  53. package/theme/components/icons/IconExclamationCircle.vue +12 -0
  54. package/theme/components/icons/IconExclamationTriangle.vue +10 -0
  55. package/theme/components/icons/IconExternalLink.vue +12 -0
  56. package/theme/components/icons/IconGit.vue +7 -0
  57. package/theme/components/icons/IconGitHub.vue +10 -0
  58. package/theme/components/icons/IconHeart.vue +9 -0
  59. package/theme/components/icons/IconInformationCircle.vue +10 -0
  60. package/theme/components/icons/IconLighthouse.vue +83 -0
  61. package/theme/components/icons/IconLine.vue +10 -0
  62. package/theme/components/icons/IconMarkdown.vue +13 -0
  63. package/theme/components/icons/IconMenu.vue +12 -0
  64. package/theme/components/icons/IconMenuAlt.vue +10 -0
  65. package/theme/components/icons/IconMinus.vue +10 -0
  66. package/theme/components/icons/IconMoon.vue +10 -0
  67. package/theme/components/icons/IconNuxt.vue +14 -0
  68. package/theme/components/icons/IconNuxtContent.vue +20 -0
  69. package/theme/components/icons/IconNuxtLabs.vue +21 -0
  70. package/theme/components/icons/IconPlus.vue +10 -0
  71. package/theme/components/icons/IconPuzzle.vue +8 -0
  72. package/theme/components/icons/IconSSG.vue +7 -0
  73. package/theme/components/icons/IconSearch.vue +12 -0
  74. package/theme/components/icons/IconSun.vue +10 -0
  75. package/theme/components/icons/IconTailwind.vue +3 -0
  76. package/theme/components/icons/IconTocBack.vue +21 -0
  77. package/theme/components/icons/IconTocCurrent.vue +21 -0
  78. package/theme/components/icons/IconTocNext.vue +8 -0
  79. package/theme/components/icons/IconTranslate.vue +14 -0
  80. package/theme/components/icons/IconTwitter.vue +8 -0
  81. package/theme/components/icons/IconVite.vue +30 -0
  82. package/theme/components/icons/IconVue.vue +6 -0
  83. package/theme/components/icons/IconVueTelescope.vue +11 -0
  84. package/theme/components/icons/IconWindi.vue +17 -0
  85. package/theme/components/icons/IconX.vue +12 -0
  86. package/theme/components/icons/IconXCircle.vue +10 -0
  87. package/theme/components/icons/IconZap.vue +8 -0
  88. package/theme/components/prose/ProseA.vue +66 -0
  89. package/theme/components/prose/ProseBlockquote.vue +21 -0
  90. package/theme/components/prose/ProseCode.vue +67 -0
  91. package/theme/components/prose/ProseCodeInline.vue +38 -0
  92. package/theme/components/prose/ProseEm.vue +11 -0
  93. package/theme/components/prose/ProseH1.vue +22 -0
  94. package/theme/components/prose/ProseH2.vue +22 -0
  95. package/theme/components/prose/ProseH3.vue +24 -0
  96. package/theme/components/prose/ProseH4.vue +24 -0
  97. package/theme/components/prose/ProseHr.vue +13 -0
  98. package/theme/components/prose/ProseImg.vue +30 -0
  99. package/theme/components/prose/ProseLi.vue +31 -0
  100. package/theme/components/prose/ProseOl.vue +16 -0
  101. package/theme/components/prose/ProseP.vue +14 -0
  102. package/theme/components/prose/ProseStrong.vue +14 -0
  103. package/theme/components/prose/ProseTable.vue +13 -0
  104. package/theme/components/prose/ProseTbody.vue +5 -0
  105. package/theme/components/prose/ProseTd.vue +11 -0
  106. package/theme/components/prose/ProseTh.vue +11 -0
  107. package/theme/components/prose/ProseThead.vue +11 -0
  108. package/theme/components/prose/ProseTr.vue +11 -0
  109. package/theme/components/prose/ProseUl.vue +15 -0
  110. package/theme/composables/useDocus.ts +43 -0
  111. package/theme/composables/useMenu.ts +7 -0
  112. package/theme/composables/useScrollToHeading.ts +35 -0
  113. package/theme/composables/useScrollspy.ts +46 -0
  114. package/theme/composables/useUserAgent.ts +7 -0
  115. package/theme/composables/utils.ts +4 -0
  116. package/theme/layouts/default.vue +29 -0
  117. package/theme/layouts/page.vue +19 -0
  118. package/theme/middleware/components.ts +26 -0
  119. package/theme/middleware/navigation.global.ts +12 -0
  120. package/theme/middleware/page.ts +8 -0
  121. package/theme/middleware/theme.global.ts +12 -0
  122. package/theme/nuxt.config.ts +171 -0
  123. package/theme/pages/[...slug].vue +64 -0
  124. package/theme/plugins/menu.ts +67 -0
  125. package/theme/plugins/user-agent.ts +27 -0
  126. package/theme/utils/components.ts +25 -0
  127. package/theme/utils/navigation.ts +49 -0
  128. package/theme/utils/plugin.ts +21 -0
  129. package/theme/utils/queries.ts +68 -0
  130. package/theme/utils/state.ts +33 -0
  131. package/theme/utils/theme.ts +66 -0
  132. package/dist/create-docus/create-docus.js +0 -7
  133. package/dist/create-docus/helpers.js +0 -244
  134. package/dist/create-docus/index.js +0 -87
  135. package/dist/index.js +0 -10
@@ -0,0 +1,49 @@
1
+ import type { NavItem } from '@nuxt/content/dist/runtime/types'
2
+
3
+ /**
4
+ * Find first child link from a navigation node.
5
+ */
6
+ export const findBottomLink = (link: NavItem) => {
7
+ for (const child of link.children) {
8
+ if (!child.children)
9
+ return child.slug
10
+ }
11
+
12
+ for (const child of link.children) {
13
+ const result = findBottomLink(child)
14
+ if (result)
15
+ return result
16
+ }
17
+ }
18
+
19
+ /**
20
+ * Find current navigation directory from a path.
21
+ */
22
+ export const navFromPath = (path: string, tree: NavItem[]) => {
23
+ for (const file of tree) {
24
+ if (file.slug === path && !file.id)
25
+ return file
26
+
27
+ if (file.children) {
28
+ const result = navFromPath(path, file.children)
29
+ if (result)
30
+ return result
31
+ }
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Find a navigation node from a path.
37
+ */
38
+ export const fileFromPath = (path: string, tree: NavItem[]) => {
39
+ for (const file of tree) {
40
+ if (file.children) {
41
+ const result = fileFromPath(path, file.children)
42
+ if (result)
43
+ return result
44
+ }
45
+
46
+ if (file.slug === path)
47
+ return file
48
+ }
49
+ }
@@ -0,0 +1,21 @@
1
+ import { queryNavigation, queryPage, queryTheme } from './queries'
2
+ import { defineNuxtPlugin, useRoute } from '#imports'
3
+
4
+ /**
5
+ * Plugin enabled only in development
6
+ * Ensure hot reload works with content sources
7
+ */
8
+ export default defineNuxtPlugin(
9
+ (nuxt) => {
10
+ nuxt.hook(
11
+ 'app:data:refresh',
12
+ async () => {
13
+ const route = useRoute()
14
+
15
+ await queryNavigation()
16
+ await queryTheme()
17
+ await queryPage(route)
18
+ },
19
+ )
20
+ },
21
+ )
@@ -0,0 +1,68 @@
1
+ import { withoutTrailingSlash } from 'ufo'
2
+ import type { ParsedContent } from '@nuxt/content/dist/runtime/types'
3
+ import type { RouteLocationNormalized, RouteLocationNormalizedLoaded } from 'vue-router'
4
+ import { defaultThemeConfig } from './theme'
5
+ import { useDocusState } from './state'
6
+ import { fetchContentNavigation, queryContent } from '#imports'
7
+
8
+ export const queryPage = async (route: RouteLocationNormalized | RouteLocationNormalizedLoaded) => {
9
+ const path = withoutTrailingSlash(route.path)
10
+
11
+ const { page, surround } = useDocusState()
12
+
13
+ try {
14
+ await Promise.all([
15
+ queryContent().where({ slug: path }).findOne() as Promise<ParsedContent>,
16
+ queryContent().where({ partial: { $not: true }, navigation: { $not: false } }).findSurround(path) as Promise<ParsedContent[]>,
17
+ ]).then(
18
+ ([_page, _surround]) => {
19
+ if (_page)
20
+ page.value = _page
21
+ else page.value = undefined
22
+
23
+ if (_surround && _surround.length)
24
+ surround.value = _surround
25
+ else surround.value = undefined
26
+
27
+ // Handle layout update from page
28
+ if (_page?.layout)
29
+ route.meta.layout = _page?.layout
30
+ else
31
+ route.meta.layout = 'default'
32
+ },
33
+ )
34
+ }
35
+ catch (e) {
36
+ console.warn(`Could not find page for path ${path}!`)
37
+ page.value = undefined
38
+ surround.value = undefined
39
+ }
40
+ }
41
+
42
+ export const queryNavigation = async () => {
43
+ const { navigation } = useDocusState()
44
+
45
+ navigation.value = await fetchContentNavigation(queryContent().where({
46
+ navigation: {
47
+ $not: false,
48
+ },
49
+ }))
50
+ }
51
+
52
+ export const queryTheme = async () => {
53
+ const { theme } = useDocusState()
54
+
55
+ // Fetch _theme.yml at `content/` root.
56
+ const query = await queryContent().where({
57
+ id: 'content:_theme.yml',
58
+ }).findOne()
59
+
60
+ if (!query) {
61
+ // Assign default theme config if none found.
62
+ theme.value = defaultThemeConfig
63
+
64
+ return
65
+ }
66
+
67
+ theme.value = query.body
68
+ }
@@ -0,0 +1,33 @@
1
+ import type { NavItem, ParsedContent } from '@nuxt/content/dist/runtime/types'
2
+ import type { ThemeConfig } from './theme'
3
+ import { useState } from '#imports'
4
+
5
+ export const useDocusState = () => {
6
+ /**
7
+ * Navigation tree from root of app.
8
+ */
9
+ const navigation = useState<NavItem[]>('docus-navigation', () => null)
10
+
11
+ /**
12
+ * Current page complete data.
13
+ */
14
+ const page = useState<ParsedContent>('docus-page', () => null)
15
+
16
+ /**
17
+ * Previous and next page data.
18
+ * Format: [prev, next]
19
+ */
20
+ const surround = useState<ParsedContent[]>('docus-page-surround', () => null)
21
+
22
+ /**
23
+ * Theme configuration.
24
+ */
25
+ const theme = useState<ThemeConfig>('docus-theme', () => null)
26
+
27
+ return {
28
+ navigation,
29
+ page,
30
+ surround,
31
+ theme,
32
+ }
33
+ }
@@ -0,0 +1,66 @@
1
+ export interface ThemeIcon {
2
+ label: string
3
+ href: string
4
+ component: string
5
+ }
6
+
7
+ export interface ThemeDebugConfig {
8
+ page: boolean
9
+ navigation: boolean
10
+ theme: boolean
11
+ }
12
+
13
+ export interface ThemeConfig {
14
+ title: string
15
+ url: string
16
+ description: string
17
+ twitter: string
18
+ github: string
19
+ cover: string
20
+ coverAlt: string
21
+ header: {
22
+ title: false | string
23
+ logo: boolean | string
24
+ }
25
+ footer: {
26
+ credits: false | {
27
+ icon: string
28
+ text: string
29
+ }
30
+ icons: ThemeIcon[]
31
+ }
32
+ debug: boolean | ThemeDebugConfig
33
+ }
34
+
35
+ export const defaultThemeConfig: ThemeConfig = {
36
+ title: 'Docus',
37
+ url: 'https://docus.dev',
38
+ twitter: '@docus_',
39
+ github: 'nuxtlabs/docus',
40
+ description: 'Write pages in markdown, use Vue components and enjoy the power of Nuxt with a blazing fast developer experience.',
41
+ header: {
42
+ title: false,
43
+ logo: true,
44
+ },
45
+ cover: 'https://user-images.githubusercontent.com/904724/105075054-872fac80-5a89-11eb-8aab-46dd254ad986.png',
46
+ coverAlt: 'A screenshot of a website built with Docus with the Docus logo on top of it.',
47
+ footer: {
48
+ credits: {
49
+ icon: 'IconNuxtLabs',
50
+ text: 'Made by NuxtLabs',
51
+ },
52
+ icons: [
53
+ {
54
+ label: 'NuxtJS',
55
+ href: 'https://nuxtjs.org',
56
+ component: 'IconNuxtLabs',
57
+ },
58
+ {
59
+ label: 'Vue Telescope',
60
+ href: 'https://vuetelescope.com',
61
+ component: 'IconVueTelescope',
62
+ },
63
+ ],
64
+ },
65
+ debug: true,
66
+ }
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- // #!/usr/bin/env node
3
- "use strict";
4
-
5
- var _index = require("./index");
6
-
7
- (0, _index.createDocus)().catch(console.log);
@@ -1,244 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getProjectType = getProjectType;
7
- exports.getTemplate = getTemplate;
8
- exports.createDir = createDir;
9
- exports.getValidPackageName = getValidPackageName;
10
- exports.getTargetDir = getTargetDir;
11
- exports.createProject = createProject;
12
- exports.log = exports.pkgManager = exports.args = exports.cwd = void 0;
13
-
14
- var _package = require("../../package.json");
15
-
16
- var _fs = _interopRequireDefault(require("fs"));
17
-
18
- var _path = _interopRequireDefault(require("path"));
19
-
20
- var _kolorist = require("kolorist");
21
-
22
- var _minimist = _interopRequireDefault(require("minimist"));
23
-
24
- var _prompts = _interopRequireDefault(require("prompts"));
25
-
26
- var _degit = _interopRequireDefault(require("degit"));
27
-
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
- const cwd = process.cwd();
31
- exports.cwd = cwd;
32
- const args = (0, _minimist.default)(process.argv.slice(2));
33
- exports.args = args;
34
- const pkgManager = /pnpm/.test(process.env.npm_execpath || "") || /pnpm/.test(process.env.npm_config_user_agent || "") ? "pnpm" : /yarn/.test(process.env.npm_execpath || "") ? "yarn" : "npm";
35
- exports.pkgManager = pkgManager;
36
- const log = {
37
- space: () => console.log(),
38
- bold: str => (0, _kolorist.bold)(str),
39
- primary: str => (0, _kolorist.green)(str),
40
- secondary: str => (0, _kolorist.dim)(str),
41
- warning: str => (0, _kolorist.yellow)(str),
42
- error: str => (0, _kolorist.red)(str),
43
- broadcast: str => console.log(` ${str}`),
44
- motd: () => {
45
- log.space();
46
- log.broadcast(`${(0, _kolorist.bold)("Docus") + log.secondary(" CLI")} ${log.primary(`v${_package.version}`)}`);
47
- log.space();
48
- }
49
- };
50
- exports.log = log;
51
- const REPOSITORIES = {
52
- website: "git@github.com:docusgen/starter.git",
53
- theme: "git@github.com:docusgen/theme-starter.git",
54
- module: "git@github.com:docusgen/module-starter.git"
55
- };
56
-
57
- function copyDir(srcDir, destDir) {
58
- _fs.default.mkdirSync(destDir, {
59
- recursive: true
60
- });
61
-
62
- for (const file of _fs.default.readdirSync(srcDir)) {
63
- const srcFile = _path.default.resolve(srcDir, file);
64
-
65
- const destFile = _path.default.resolve(destDir, file);
66
-
67
- copy(srcFile, destFile);
68
- }
69
- }
70
-
71
- function emptyDir(dir) {
72
- if (!_fs.default.existsSync(dir)) return;
73
-
74
- for (const file of _fs.default.readdirSync(dir)) {
75
- const abs = _path.default.resolve(dir, file);
76
-
77
- if (_fs.default.lstatSync(abs).isDirectory()) {
78
- emptyDir(abs);
79
-
80
- _fs.default.rmdirSync(abs);
81
- } else {
82
- _fs.default.unlinkSync(abs);
83
- }
84
- }
85
- }
86
-
87
- function copy(src, dest) {
88
- const stat = _fs.default.statSync(src);
89
-
90
- if (stat.isDirectory()) copyDir(src, dest);else _fs.default.copyFileSync(src, dest);
91
- }
92
-
93
- function getProjectType() {
94
- switch (args["type"]) {
95
- case "theme":
96
- return "theme";
97
-
98
- case "module":
99
- return "module";
100
-
101
- default:
102
- return "website";
103
- }
104
- }
105
-
106
- async function getTemplate(projectType) {
107
- const {
108
- broadcast,
109
- primary,
110
- secondary
111
- } = log;
112
-
113
- const templateDir = _path.default.join(__dirname, "./template");
114
-
115
- broadcast([secondary("Cloning the latest"), primary(projectType === "website" ? "Docus" : projectType), secondary("template...")].join(" "));
116
- emptyDir(templateDir);
117
- const projectRepository = REPOSITORIES[projectType];
118
- const repo = (0, _degit.default)(projectRepository, {
119
- force: true,
120
- verbose: true,
121
- mode: "git"
122
- });
123
- await repo.clone(templateDir);
124
- return templateDir;
125
- }
126
-
127
- async function createDir(targetDir) {
128
- const projectPath = _path.default.join(cwd, targetDir);
129
-
130
- const {
131
- broadcast,
132
- warning,
133
- error,
134
- space,
135
- secondary
136
- } = log;
137
-
138
- if (!_fs.default.existsSync(projectPath)) {
139
- _fs.default.mkdirSync(projectPath, {
140
- recursive: true
141
- });
142
- } else {
143
- const existing = _fs.default.readdirSync(projectPath);
144
-
145
- const dir = projectPath.split("/");
146
- const dirName = dir[dir.length - 1];
147
-
148
- if (existing.length) {
149
- space();
150
- broadcast(warning(`Target directory "${dirName}" is not empty.`));
151
- space();
152
- const {
153
- yes
154
- } = await (0, _prompts.default)({
155
- type: "confirm",
156
- name: "yes",
157
- initial: "Y",
158
- message: "Remove existing files and continue?"
159
- });
160
- if (yes) emptyDir(projectPath);else {
161
- space();
162
- broadcast(warning(`Target directory is not empty and you do not want to overwrite it.`));
163
- space();
164
- broadcast(error(`Cancelling project creation.`));
165
- process.exit(1);
166
- }
167
- }
168
- }
169
-
170
- space();
171
- broadcast(secondary("Scaffolding project in ") + targetDir + secondary("..."));
172
- return projectPath;
173
- }
174
-
175
- async function getValidPackageName(projectName) {
176
- projectName = _path.default.basename(projectName);
177
- const packageNameRegExp = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
178
-
179
- if (packageNameRegExp.test(projectName)) {
180
- return projectName;
181
- } else {
182
- const suggestedPackageName = projectName.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
183
- const {
184
- inputPackageName
185
- } = await (0, _prompts.default)({
186
- type: "text",
187
- name: "inputPackageName",
188
- message: "Package name:",
189
- initial: suggestedPackageName,
190
- validate: input => packageNameRegExp.test(input) ? true : "Invalid package.json name"
191
- });
192
- return inputPackageName;
193
- }
194
- }
195
-
196
- async function getTargetDir(projectType) {
197
- const {
198
- space,
199
- broadcast,
200
- error,
201
- warning
202
- } = log;
203
- let targetDir = args._[0];
204
-
205
- if (!targetDir) {
206
- const {
207
- projectName
208
- } = await (0, _prompts.default)({
209
- type: "text",
210
- name: "projectName",
211
- message: "Project name:",
212
- initial: `my-${projectType}`
213
- });
214
-
215
- if (!projectName) {
216
- space();
217
- broadcast(warning(`You must specify a project name.`));
218
- space();
219
- broadcast(error(`Cancelling project creation.`));
220
- process.exit(1);
221
- }
222
-
223
- targetDir = projectName.trim();
224
- }
225
-
226
- return targetDir;
227
- }
228
-
229
- function createProject(root, templateDir, packageName) {
230
- const write = (file, content = void 0) => {
231
- const targetPath = _path.default.join(root, file);
232
-
233
- if (content) _fs.default.writeFileSync(targetPath, content);else copy(_path.default.join(templateDir, file), targetPath);
234
- };
235
-
236
- const files = _fs.default.readdirSync(templateDir);
237
-
238
- for (const file of files.filter(f => f !== "package.json")) write(file);
239
-
240
- const pkg = require(_path.default.join(templateDir, "package.json"));
241
-
242
- pkg.name = packageName;
243
- write("package.json", JSON.stringify(pkg, null, 2));
244
- }
@@ -1,87 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createDocus = createDocus;
7
-
8
- var _path = require("path");
9
-
10
- var _prompts = _interopRequireDefault(require("prompts"));
11
-
12
- var _execa = _interopRequireDefault(require("execa"));
13
-
14
- var _helpers = require("./helpers");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- const {
19
- motd,
20
- primary,
21
- secondary,
22
- warning,
23
- bold,
24
- space,
25
- broadcast
26
- } = _helpers.log;
27
-
28
- async function createDocus() {
29
- motd();
30
- const projectType = (0, _helpers.getProjectType)();
31
- const targetDir = await (0, _helpers.getTargetDir)(projectType);
32
- const packageName = await (0, _helpers.getValidPackageName)(targetDir);
33
- const projectPath = await (0, _helpers.createDir)(targetDir);
34
- const templateDir = await (0, _helpers.getTemplate)(projectType);
35
- (0, _helpers.createProject)(projectPath, templateDir, packageName);
36
- broadcast(primary("Done."));
37
- space();
38
- const {
39
- yes
40
- } = await (0, _prompts.default)({
41
- type: "confirm",
42
- name: "yes",
43
- initial: "Y",
44
- message: "Install and start it now?"
45
- });
46
- if (yes) await startProject(projectPath);else startItLater(projectPath);
47
- }
48
-
49
- async function startProject(projectPath) {
50
- space();
51
- const {
52
- agent
53
- } = await (0, _prompts.default)({
54
- name: "agent",
55
- type: "select",
56
- message: "Choose the agent",
57
- choices: ["yarn", "npm", "pnpm"].map(i => ({
58
- value: i,
59
- title: i
60
- }))
61
- });
62
-
63
- if (!agent) {
64
- space();
65
- broadcast(warning(`You cancelled the agent selection!`));
66
- return startItLater(projectPath);
67
- }
68
-
69
- await (0, _execa.default)(agent, ["install"], {
70
- stdio: "inherit",
71
- cwd: projectPath
72
- });
73
- await (0, _execa.default)(agent, ["run", "dev"], {
74
- stdio: "inherit",
75
- cwd: projectPath
76
- });
77
- }
78
-
79
- function startItLater(projectPath) {
80
- space();
81
- broadcast(secondary("Start it later with:"));
82
- space();
83
- const dir = (0, _path.relative)(_helpers.cwd, projectPath);
84
- if (projectPath !== _helpers.cwd) broadcast(primary(`cd ${bold(dir)}`));
85
- broadcast(primary(`${_helpers.pkgManager === "yarn" ? "yarn" : `${_helpers.pkgManager} install`}`));
86
- broadcast(primary(`${_helpers.pkgManager === "yarn" ? "yarn dev" : `${_helpers.pkgManager} run dev`}`));
87
- }
package/dist/index.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- module.exports = void 0;
7
-
8
- var _default = () => {};
9
-
10
- module.exports = _default;