@notifiles/sdk 1.1.2 → 1.1.3

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 (33) hide show
  1. package/package.json +1 -1
  2. package/src/lib/entries/getAtPath.js +4 -3
  3. package/src/project/index.js +1 -1
  4. package/src/template/cloudify/lib/email/image/index.js +0 -1
  5. package/src/template/lib/activity/createFileIfNeeded.js +4 -2
  6. package/src/template/lib/i18n/createFileIfNeeded.js +33 -0
  7. package/src/template/lib/i18n/defaultContent.json +1 -0
  8. package/src/template/lib/{manifest/read.js → i18n/get.js} +3 -5
  9. package/src/template/lib/i18n/updateToFile.js +32 -0
  10. package/src/template/lib/manifest/createFileIfNeeded.js +8 -16
  11. package/src/template/lib/manifest/defaultContent.json +9 -0
  12. package/src/template/lib/manifest/get.js +20 -0
  13. package/src/template/lib/manifest/updateToFile.js +13 -2
  14. package/src/template/new/index.js +32 -26
  15. package/src/template/new/index.test.js +4 -7
  16. package/src/template/new/lib/slugify.js +16 -0
  17. package/src/template/new/templates/email.mastered.js +13 -0
  18. package/src/template/new/templates/email.tsx.js +61 -0
  19. package/src/template/new/templates/pushnotification.js +4 -0
  20. package/src/template/new/templates/textmessage.js +4 -0
  21. package/src/template/update/path.js +3 -6
  22. package/src/template/update/path.test.js +1 -1
  23. package/src/project/new/index.js +0 -2
  24. package/src/project/new/plain.js +0 -49
  25. package/src/project/new/plain.test.js +0 -38
  26. package/src/template/lib/manifest/update.js +0 -18
  27. package/src/template/version/entry.js +0 -10
  28. package/src/template/version/index.js +0 -2
  29. package/src/template/version/lib/perform.js +0 -74
  30. package/src/template/version/lib/reset.js +0 -16
  31. package/src/template/version/lib/updatePost.js +0 -16
  32. package/src/template/version/path.js +0 -20
  33. package/src/template/version/path.test.js +0 -16
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@notifiles/sdk",
3
3
  "type": "module",
4
- "version": "1.1.2",
4
+ "version": "1.1.3",
5
5
  "description": "",
6
6
  "author": {
7
7
  "name": "adoucoure",
@@ -6,6 +6,8 @@ import isPathEntry from './isPathEntry.js'
6
6
  import importJSONAsync from "../fs/importJSONAsync.js"
7
7
  import slug from 'slug'
8
8
  import createActivityIfNeeded from '../../template/lib/activity/createFileIfNeeded.js'
9
+ import createManifestIfNeeded from '../../template/lib/manifest/createFileIfNeeded.js'
10
+ import createi18nIfNeeded from '../../template/lib/i18n/createFileIfNeeded.js'
9
11
 
10
12
  const perform = async (props) => {
11
13
  const {
@@ -44,14 +46,14 @@ const perform = async (props) => {
44
46
  })
45
47
  }
46
48
 
47
-
48
49
  let testMessagePath = fsPath.join(folderPath, 'textmessage.txt')
49
50
  let pushPath = fsPath.join(folderPath, 'pushnotification.txt')
50
51
  const i18nPath = fsPath.join(folderPath, 'i18n.json')
51
52
  let manifest = await importJSONAsync(fsPath.join(folderPath, 'manifest.json'))
52
53
 
53
54
  await createActivityIfNeeded({ path: folderPath })
54
-
55
+ await createManifestIfNeeded({ path: folderPath })
56
+ await createi18nIfNeeded({ path: folderPath })
55
57
 
56
58
  let activity
57
59
  const activityPath = fsPath.join(folderPath, '.activity.json')
@@ -78,7 +80,6 @@ const perform = async (props) => {
78
80
  i18n = await importJSONAsync(i18nPath)
79
81
  }
80
82
 
81
-
82
83
  return [{
83
84
  name: item,
84
85
  slug: slug(item),
@@ -1,4 +1,4 @@
1
1
 
2
2
  export { default as isProject } from './isProject/index.js'
3
3
  export { default as isProjectSync } from './isProject/sync.js'
4
- export * as newProject from './new/index.js'
4
+
@@ -80,7 +80,6 @@ export default async ({ child,
80
80
  content: _activity,
81
81
  })
82
82
 
83
-
84
83
  return {
85
84
  ...child,
86
85
  properties: {
@@ -5,7 +5,9 @@ import importJSONAsync from '../../../lib/fs/importJSONAsync.js'
5
5
 
6
6
  export default async ({
7
7
  path,
8
- status = "draft",
8
+ data = {
9
+ status: "draft"
10
+ },
9
11
  }) => {
10
12
 
11
13
 
@@ -21,7 +23,7 @@ export default async ({
21
23
  let content = {
22
24
  ...defaultContent,
23
25
  createdAt: (new Date()),
24
- status,
26
+ ...data,
25
27
  }
26
28
 
27
29
  await fs.promises.writeFile(filePath, JSON.stringify(content, null, 2))
@@ -0,0 +1,33 @@
1
+ import fsPath from 'path'
2
+ import fs from 'fs'
3
+ import checkFileExists from '../../../lib/fs/checkFileExists.js'
4
+ import importJSONAsync from '../../../lib/fs/importJSONAsync.js'
5
+
6
+ export default async ({
7
+ path,
8
+ data = {},
9
+ }) => {
10
+
11
+
12
+ try {
13
+
14
+ const filePath = fsPath.join(path, "i18n.json")
15
+
16
+ if ((await checkFileExists(filePath))) {
17
+ return
18
+ }
19
+
20
+ const defaultContent = await importJSONAsync('./defaultContent.json')
21
+ let content = {
22
+ ...defaultContent,
23
+ createdAt: (new Date()),
24
+ ...data,
25
+ }
26
+
27
+ await fs.promises.writeFile(filePath, JSON.stringify(content, null, 2))
28
+ return true
29
+ } catch (e) {
30
+ console.error(e)
31
+ }
32
+ return false
33
+ }
@@ -1,20 +1,18 @@
1
1
  import fsPath from 'path'
2
2
  import checkFileExists from '../../../lib/fs/checkFileExists.js'
3
- import importYAMLAsync from '../../../lib/fs/importYAMLAsync.js'
4
-
3
+ import importJSONAsync from '../../../lib/fs/importJSONAsync.js'
5
4
 
6
5
  export default async ({
7
6
  path,
8
7
  }) => {
9
8
  try {
10
- const filePath = fsPath.join(path, "manifest.yaml")
9
+ const filePath = fsPath.join(path, "i18n.json")
11
10
 
12
11
  if (!(await checkFileExists(filePath))) {
13
12
  return null
14
13
  }
15
14
 
16
- const content = await importYAMLAsync(manifestPath)
17
- return content
15
+ return importJSONAsync(filePath)
18
16
  } catch (e) {
19
17
  console.error(e)
20
18
  }
@@ -0,0 +1,32 @@
1
+ import fsPath from 'path'
2
+ import fs from 'fs'
3
+ import checkFileExists from '../../../lib/fs/checkFileExists.js'
4
+ import importJSONAsync from '../../../lib/fs/importJSONAsync.js'
5
+
6
+ export default async ({
7
+ path,
8
+ content,
9
+ }) => {
10
+
11
+
12
+ try {
13
+
14
+ const filePath = fsPath.join(path, "i18n.json")
15
+
16
+ if (!(await checkFileExists(filePath))) {
17
+ return
18
+ }
19
+
20
+ const defaultContent = await importJSONAsync('./defaultContent.json')
21
+ let _content = {
22
+ ...defaultContent,
23
+ ...content,
24
+ }
25
+
26
+ await fs.promises.writeFile(filePath, JSON.stringify(_content, null, 2))
27
+ return true
28
+ } catch (e) {
29
+ console.error(e)
30
+ }
31
+ return false
32
+ }
@@ -1,38 +1,30 @@
1
1
  import fsPath from 'path'
2
2
  import fs from 'fs'
3
3
  import checkFileExists from '../../../lib/fs/checkFileExists.js'
4
- import YAML from 'yaml'
4
+ import importJSONAsync from '../../../lib/fs/importJSONAsync.js'
5
5
 
6
6
  export default async ({
7
7
  path,
8
- data = {}
8
+ data = {},
9
9
  }) => {
10
10
 
11
11
 
12
12
  try {
13
13
 
14
- const filePath = fsPath.join(path, "manifest.yaml")
14
+ const filePath = fsPath.join(path, "manifest.json")
15
15
 
16
16
  if ((await checkFileExists(filePath))) {
17
17
  return
18
18
  }
19
19
 
20
-
21
- let defaultManifest = YAML.parse(`
22
- status: draft
23
- skip: false
24
- license: all-rights-reserved
25
- `)
26
-
27
- let manifest = {
28
- ...defaultManifest,
20
+ const defaultContent = await importJSONAsync('./defaultContent.json')
21
+ let content = {
22
+ ...defaultContent,
29
23
  createdAt: (new Date()),
30
- ...data
24
+ ...data,
31
25
  }
32
26
 
33
- manifest = YAML.stringify(manifest)
34
-
35
- await fs.promises.writeFile(filePath, manifest)
27
+ await fs.promises.writeFile(filePath, JSON.stringify(content, null, 2))
36
28
  return true
37
29
  } catch (e) {
38
30
  console.error(e)
@@ -0,0 +1,9 @@
1
+ {
2
+ "id": "codevalidation",
3
+ "groupId": "",
4
+ "dependsOnUser": true,
5
+ "agent": {
6
+ "type": "manual",
7
+ "params": {}
8
+ }
9
+ }
@@ -0,0 +1,20 @@
1
+ import fsPath from 'path'
2
+ import checkFileExists from '../../../lib/fs/checkFileExists.js'
3
+ import importJSONAsync from '../../../lib/fs/importJSONAsync.js'
4
+
5
+ export default async ({
6
+ path,
7
+ }) => {
8
+ try {
9
+ const filePath = fsPath.join(path, "manifest.json")
10
+
11
+ if (!(await checkFileExists(filePath))) {
12
+ return null
13
+ }
14
+
15
+ return importJSONAsync(filePath)
16
+ } catch (e) {
17
+ console.error(e)
18
+ }
19
+ return null
20
+ }
@@ -1,19 +1,30 @@
1
1
  import fsPath from 'path'
2
2
  import fs from 'fs'
3
3
  import checkFileExists from '../../../lib/fs/checkFileExists.js'
4
+ import importJSONAsync from '../../../lib/fs/importJSONAsync.js'
5
+
4
6
 
5
7
  export default async ({
6
8
  path,
7
9
  content,
8
10
  }) => {
9
11
 
12
+
10
13
  try {
11
- const filePath = fsPath.join(path, "manifest.yaml")
14
+
15
+ const filePath = fsPath.join(path, "manifest.json")
16
+
12
17
  if (!(await checkFileExists(filePath))) {
13
18
  return
14
19
  }
15
20
 
16
- await fs.promises.writeFile(filePath, content)
21
+ const defaultContent = await importJSONAsync('./defaultContent.json')
22
+ let _content = {
23
+ ...defaultContent,
24
+ ...content,
25
+ }
26
+
27
+ await fs.promises.writeFile(filePath, JSON.stringify(_content, null, 2))
17
28
  return true
18
29
  } catch (e) {
19
30
  console.error(e)
@@ -1,24 +1,26 @@
1
1
  import fsPath from 'path'
2
2
  import fs from 'fs'
3
3
  import checkFileExists from '../../lib/fs/checkFileExists.js'
4
- import createStatusIfNeeded from '../lib/activity/createFileIfNeeded.js'
4
+ import createActivityIfNeeded from '../lib/activity/createFileIfNeeded.js'
5
5
  import createManifestIfNeeded from '../lib/manifest/createFileIfNeeded.js'
6
+ import createi18nIfNeeded from '../lib/i18n/createFileIfNeeded.js'
7
+ import emailTemplate from './templates/email.tsx.js'
8
+ import emailTemplateMaster from './templates/email.mastered.js'
9
+ import textmessageTemplate from './templates/textmessage.js'
10
+ import pushnotificationTemplate from './templates/pushnotification.js'
11
+ import _slug from 'slug'
6
12
 
7
13
  export default async ({
8
14
  path,
9
- title = "My new post",
10
- platforms = [],
11
- status = "draft",
12
- canonicalUrl = "",
15
+ title = "My new template",
13
16
  tags,
14
- author = {
15
- id: "",
16
- name: ""
17
- },
18
- force = false
17
+ i18n = {},
18
+ force = false,
19
+ emailType = 'mastered'
19
20
  }) => {
20
21
  try {
21
- const folderPath = fsPath.join(path, title)
22
+ const slug = _slug(title)
23
+ const folderPath = fsPath.join(path, slug)
22
24
 
23
25
  if ((await checkFileExists(folderPath))) {
24
26
  if (!force) {
@@ -28,39 +30,43 @@ export default async ({
28
30
  }
29
31
 
30
32
  await fs.promises.mkdir(folderPath)
31
- await fs.promises.mkdir(`${folderPath}/.assets`)
32
- // await fs.promises.mkdir(`${folderPath}/artefacts`)
33
- await fs.promises.mkdir(`${folderPath}/.build`)
33
+ await fs.promises.mkdir(`${folderPath}/attachments`)
34
+ await fs.promises.mkdir(`${folderPath}/.cache`)
34
35
 
35
-
36
- await createStatusIfNeeded({
36
+ await createActivityIfNeeded({
37
37
  path: folderPath
38
38
  })
39
39
 
40
40
  await createManifestIfNeeded({
41
41
  path: folderPath,
42
42
  data: {
43
+ id: slug,
43
44
  name: title,
44
- platforms,
45
- canonicalUrl,
46
- status,
47
- author,
48
45
  tags
49
46
  }
50
47
  })
51
48
 
49
+ await createi18nIfNeeded({
50
+ path: folderPath,
51
+ data: i18n
52
+ })
52
53
 
53
- const postPath = fsPath.join(folderPath, "post.md")
54
- const post = `# ${title}`
55
- await fs.promises.writeFile(postPath, post, 'utf8')
54
+ const emailPath = fsPath.join(folderPath, "email.tsx")
55
+ const email = (emailType === 'mastered') ? await emailTemplateMaster({}) : await emailTemplate({})
56
+ await fs.promises.writeFile(emailPath, email, 'utf8')
56
57
 
57
- const excerptPath = fsPath.join(folderPath, "excerpt.md")
58
- const excerpt = ``
59
- await fs.promises.writeFile(excerptPath, excerpt, 'utf8')
58
+ const textMessagePath = fsPath.join(folderPath, "textMessage.txt")
59
+ const textMessage = await textmessageTemplate({})
60
+ await fs.promises.writeFile(textMessagePath, textMessage, 'utf8')
61
+
62
+ const pushNotificationPath = fsPath.join(folderPath, "pushnotification.txt")
63
+ const pushNotification = await pushnotificationTemplate({})
64
+ await fs.promises.writeFile(pushNotificationPath, pushNotification, 'utf8')
60
65
 
61
66
  return true
62
67
  } catch (e) {
63
68
  console.error(e)
64
69
  }
70
+
65
71
  return false
66
72
  }
@@ -1,15 +1,12 @@
1
1
 
2
- test.skip('creates a new post', async () => {
2
+ test('creates a new post', async () => {
3
3
  const fsPath = (await import('path')).default
4
- let path = fsPath.resolve("__mock__/adoucoure/Development")
5
- const operation = (await import('./new.js')).default
4
+ let path = `${fsPath.resolve(process.env.TEST_MOCK_FOLDER)}`
5
+ const operation = (await import('./index.js')).default
6
6
 
7
7
  const result = await operation({
8
- platforms: [{
9
- id: 'medium',
10
- }],
11
8
  path,
12
- title: "Sample test post",
9
+ title: "Sample template",
13
10
  force: true
14
11
  })
15
12
 
@@ -0,0 +1,16 @@
1
+ export default text => {
2
+ const from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;"
3
+ const to = "aaaaaeeeeeiiiiooooouuuunc------"
4
+
5
+ const newText = text.split('').map(
6
+ (letter, i) => letter.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)))
7
+
8
+ return newText
9
+ .toString() // Cast to string
10
+ .toLowerCase() // Convert the string to lowercase letters
11
+ .trim() // Remove whitespace from both sides of a string
12
+ .replace(/\s+/g, '-') // Replace spaces with -
13
+ .replace(/&/g, '-y-') // Replace & with 'and'
14
+ .replace(/[^\w\-]+/g, '') // Remove all non-word chars
15
+ .replace(/\-\-+/g, '-') // Replace multiple - with single -
16
+ }
@@ -0,0 +1,13 @@
1
+ export default async () => {
2
+ return `import { Text } from "../../lib/components/common"
3
+ import * as React from "react"
4
+ import Master from "../../lib/components/domain/master"
5
+
6
+ export default () => <Master
7
+ preview={"Your validation code"}>
8
+ <Text>
9
+ [[intro]]
10
+ </Text>
11
+ </Master>
12
+ `
13
+ }
@@ -0,0 +1,61 @@
1
+
2
+ export default async () => {
3
+ return `import {
4
+ Body,
5
+ Button,
6
+ Container,
7
+ Column,
8
+ Head,
9
+ Heading,
10
+ Hr,
11
+ Html,
12
+ Img,
13
+ Link,
14
+ Preview,
15
+ Row,
16
+ Section,
17
+ Text,
18
+ Tailwind,
19
+ } from "@react-email/components";
20
+ import * as React from "react";
21
+
22
+ interface EmailProps {
23
+
24
+ }
25
+
26
+ export const Email = ({
27
+ username,
28
+ userImage,
29
+ invitedByUsername,
30
+ invitedByEmail,
31
+ teamName,
32
+ teamImage,
33
+ inviteLink,
34
+ inviteFromIp,
35
+ inviteFromLocation,
36
+ }: EmailProps) => {
37
+ const previewText = \`\`;
38
+
39
+ return (
40
+ <Html>
41
+ <Head />
42
+ <Preview>{previewText}</Preview>
43
+ <Tailwind>
44
+ <Body className="bg-white my-auto mx-auto font-sans px-2">
45
+ <Container className="border border-solid border-[#eaeaea] rounded my-[40px] mx-auto p-[20px] max-w-[465px]">
46
+ <Section className="mt-[32px]">
47
+ </Section>
48
+ </Container>
49
+ </Body>
50
+ </Tailwind>
51
+ </Html>
52
+ );
53
+ };
54
+
55
+ Email.PreviewProps = {
56
+
57
+ } as EmailProps;
58
+
59
+ export default Email;
60
+ `
61
+ }
@@ -0,0 +1,4 @@
1
+
2
+ export default async () => {
3
+ return ''
4
+ }
@@ -0,0 +1,4 @@
1
+
2
+ export default async () => {
3
+ return ''
4
+ }
@@ -4,7 +4,6 @@ import build from '../build/entry.js'
4
4
  import sync from '../sync/entry.js'
5
5
  import format from '../format/entry.js'
6
6
  import optimize from '../optimize/entry.js'
7
- import version from '../version/entry.js'
8
7
  import cloudify from '../cloudify/entry.js'
9
8
  import adaptSettings from '../../lib/adaptSettings.js'
10
9
  import attach from '../attach/entry.js'
@@ -34,12 +33,10 @@ export default async ({
34
33
  entry = (await optimize({ entry, settings })).entry
35
34
  entry = (await cloudify({ entry, settings })).entry
36
35
  entry = (await attach({ entry, settings })).entry
37
- if (!settings.dryRun) {
38
- entry = (await sync({ entry, settings })).entry
36
+ if (settings.dryRun) {
37
+ continue
39
38
  }
40
-
41
-
42
- await version({})
39
+ entry = (await sync({ entry, settings })).entry
43
40
  }
44
41
 
45
42
  return true
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- describe('project', () => {
3
+ describe.skip('project', () => {
4
4
  it('Updates and syncs to minio', async () => {
5
5
  const fsPath = (await import('path')).default
6
6
  let path = `${fsPath.resolve(process.env.TEST_MOCK_FOLDER)}`
@@ -1,2 +0,0 @@
1
-
2
- export { default as plain } from './plain.js'
@@ -1,49 +0,0 @@
1
- import fsPath from 'path'
2
- import fs from 'fs'
3
- import checkFileExists from '../../lib/fs/checkFileExists.js'
4
- import createStatusIfNeeded from '../lib/activity/createFileIfNeeded.js'
5
- import createManifestIfNeeded from '../lib/manifest/createFileIfNeeded.js'
6
-
7
- export default async ({
8
- path,
9
- name = "My new project",
10
- description = "An authoring project for my personal usage.",
11
- settings = {
12
- },
13
- force = false,
14
- author = {
15
- id: "",
16
- name: ""
17
- },
18
- }) => {
19
- try {
20
- const folderPath = fsPath.join(path, name)
21
-
22
- if ((await checkFileExists(folderPath))) {
23
- if (!force) {
24
- return false
25
- }
26
- await fs.promises.rmdir(folderPath, { recursive: true })
27
- }
28
-
29
- await fs.promises.mkdir(folderPath)
30
-
31
- await createStatusIfNeeded({
32
- path: folderPath
33
- })
34
-
35
- await createManifestIfNeeded({
36
- path: folderPath,
37
- data: {
38
- name,
39
- author,
40
- description
41
- }
42
- })
43
-
44
- return true
45
- } catch (e) {
46
- console.error(e)
47
- }
48
- return false
49
- }
@@ -1,38 +0,0 @@
1
-
2
-
3
- describe.skip('project', () => {
4
- it('creates new to medium and dev.to platforms', async () => {
5
- const fsPath = (await import('path')).default
6
- let path = fsPath.resolve(process.env.TEST_MOCK_FOLDER_ROOT)
7
- const operation = (await import('./plain.js')).default
8
- const result = await operation({
9
- settings: {
10
- platforms: [{
11
- id: 'medium',
12
- auth: {
13
- token: process.env.TEST_MEDIUM_TOKEN,
14
- }
15
- },
16
- {
17
- id: 'devto',
18
- auth: {
19
- token: process.env.TEST_DEVTO_TOKEN,
20
- }
21
- }],
22
- clouds: {
23
- id: "minio",
24
- auth: {
25
- endPoint: process.env.TEST_MINIO_ENDPOINT,
26
- accessKey: process.env.TEST_MINIO_ACCESS_KEY,
27
- secretKey: process.env.TEST_MINIO_SECRET,
28
- bucketName: process.env.TEST_MINIO_BUCKET_NAME
29
- }
30
- }
31
- },
32
- name: process.env.TEST_MOCK_FOLDER_NEW_NAME,
33
- path,
34
- force: true
35
- })
36
- expect(result).toBeTruthy()
37
- })
38
- })
@@ -1,18 +0,0 @@
1
- import updateToFile from './updateToFile.js'
2
- import YAML from 'yaml'
3
-
4
- export default async ({
5
- path,
6
- manifest,
7
- }) => {
8
- try {
9
- const content = YAML.stringify(manifest)
10
- return updateToFile({
11
- path,
12
- content
13
- })
14
- } catch (e) {
15
- console.error(e)
16
- }
17
- return false
18
- }
@@ -1,10 +0,0 @@
1
- import perform from './lib/perform.js'
2
-
3
- export default async ({
4
- entry,
5
- source,
6
- settings
7
- }) => {
8
- return
9
- return perform({ entry, source, settings })
10
- }
@@ -1,2 +0,0 @@
1
- export { default as processEntry } from './entry.js'
2
- export { default as processPath } from './path.js'
@@ -1,74 +0,0 @@
1
- import markdownToLexer from '../../../lib/remark/markdownToLexer.js'
2
- import mdastToHTML from '../../../lib/remark/mdastToHTML.js'
3
- import mdastToMarkdown from '../../../lib/remark/mdastToMarkdown.js'
4
- import reset from './reset.js'
5
- import updatePost from './updatePost.js'
6
-
7
- export default async (props) => {
8
-
9
- const { entry } = props
10
- const { path, } = entry
11
- const data = props.source ? props.source : (entry.post.consolidated
12
- ? entry.post.consolidated
13
- : entry.post.source)
14
-
15
- await reset({ path })
16
-
17
- const child = markdownToLexer({
18
- data
19
- })
20
-
21
- const mdast = await perform({
22
- child,
23
- path
24
- })
25
-
26
- let md = await mdastToMarkdown({ mdast })
27
- let html = mdastToHTML({ mdast })
28
-
29
- await updatePost({
30
- path,
31
- md,
32
- html
33
- })
34
-
35
- return {
36
- md,
37
- html,
38
- entry: mdast
39
- }
40
- }
41
-
42
- const perform = async (props) => {
43
- const { child, path } = props
44
- let _child = { ...child }
45
- // switch (_child.type) {
46
- // case 'code': {
47
- // switch (_child.lang) {
48
- // case 'mermaid': {
49
- // _child = await buildMermaid({
50
- // child: _child,
51
- // path
52
- // })
53
- // } break
54
- // default:
55
- // break
56
- // }
57
- // } break
58
- // default:
59
- // break
60
- // }
61
-
62
- let _children = []
63
- if (_child.children) {
64
- _children = await Promise.all(_child.children.map(async child => perform({
65
- ...props,
66
- child
67
- })))
68
- }
69
-
70
- return {
71
- ..._child,
72
- children: _children
73
- }
74
- }
@@ -1,16 +0,0 @@
1
- import fsPath from 'path'
2
- import fs from 'fs'
3
- import checkFileExists from '../../../lib/fs/checkFileExists.js'
4
-
5
- export default async ({
6
- path, }) => {
7
-
8
- const buildPath = fsPath.join(path, "build")
9
- if (!(await checkFileExists(buildPath))) {
10
- return
11
- }
12
-
13
- let success = await fs.promises.rmdir(buildPath, { recursive: true })
14
- success = true
15
- return success
16
- }
@@ -1,16 +0,0 @@
1
- import fsPath from 'path'
2
- import fs from 'fs'
3
-
4
- export default async ({
5
- path,
6
- md,
7
- html }) => {
8
-
9
- const mdPath = fsPath.join(path, ".post.built.md")
10
- const htmlPath = fsPath.join(path, ".post.built.html")
11
-
12
- await fs.promises.writeFile(mdPath, md, 'utf8')
13
- await fs.promises.writeFile(htmlPath, html, 'utf8')
14
-
15
- return true
16
- }
@@ -1,20 +0,0 @@
1
- import perform from './lib/perform.js'
2
- import getEntries from '../../lib/entries/getAtPath.js'
3
- import adaptSettings from '../../lib/adaptSettings.js'
4
-
5
- export default async ({
6
- path,
7
- settings
8
- }) => {
9
- adaptSettings({ settings })
10
- let entries = await getEntries({
11
- path,
12
- })
13
-
14
- for (var i in entries) {
15
- const entry = entries[i]
16
- await perform({ entry, settings })
17
- }
18
-
19
- return true
20
- }
@@ -1,16 +0,0 @@
1
-
2
-
3
- test.skip('version posts', async () => {
4
- const fsPath = (await import('path')).default
5
- let path = fsPath.resolve(process.env.TEST_MOCK_FOLDER)
6
- const operation = (await import('./path.js')).default
7
-
8
- const result = await operation({
9
- settings: {
10
- },
11
- path,
12
- })
13
- expect(result).toBeTruthy()
14
- })
15
-
16
-