@notifiles/sdk 1.1.1 → 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.
- package/package.json +1 -1
- package/src/lib/cloudLibrary/minio/index.js +1 -0
- package/src/lib/cloudLibrary/minio/previewRemoteUrl.js +20 -0
- package/src/lib/entries/getAtPath.js +4 -3
- package/src/project/index.js +1 -1
- package/src/template/cloudify/lib/email/image/index.js +20 -20
- package/src/template/cloudify/lib/email/index.js +0 -2
- package/src/template/consolidate/lib/email.js +4 -4
- package/src/template/consolidate/lib/image/index.js +6 -3
- package/src/template/consolidate/lib/image/treatLocalFile.js +1 -0
- package/src/template/consolidate/lib/image/treatRemoteFile.js +2 -1
- package/src/template/format/entry.js +6 -3
- package/src/template/lib/activity/createFileIfNeeded.js +4 -2
- package/src/template/lib/i18n/createFileIfNeeded.js +33 -0
- package/src/template/lib/i18n/defaultContent.json +1 -0
- package/src/template/lib/{manifest/read.js → i18n/get.js} +3 -5
- package/src/template/lib/i18n/updateToFile.js +32 -0
- package/src/template/lib/manifest/createFileIfNeeded.js +8 -16
- package/src/template/lib/manifest/defaultContent.json +9 -0
- package/src/template/lib/manifest/get.js +20 -0
- package/src/template/lib/manifest/updateToFile.js +13 -2
- package/src/template/new/index.js +32 -26
- package/src/template/new/index.test.js +4 -7
- package/src/template/new/lib/slugify.js +16 -0
- package/src/template/new/templates/email.mastered.js +13 -0
- package/src/template/new/templates/email.tsx.js +61 -0
- package/src/template/new/templates/pushnotification.js +4 -0
- package/src/template/new/templates/textmessage.js +4 -0
- package/src/template/optimize/lib/email.js +5 -3
- package/src/template/optimize/lib/image/index.js +8 -4
- package/src/template/update/path.js +3 -6
- package/src/template/update/path.test.js +1 -1
- package/src/project/new/index.js +0 -2
- package/src/project/new/plain.js +0 -49
- package/src/project/new/plain.test.js +0 -38
- package/src/template/lib/manifest/update.js +0 -18
- package/src/template/version/entry.js +0 -10
- package/src/template/version/index.js +0 -2
- package/src/template/version/lib/perform.js +0 -74
- package/src/template/version/lib/reset.js +0 -16
- package/src/template/version/lib/updatePost.js +0 -16
- package/src/template/version/path.js +0 -20
- package/src/template/version/path.test.js +0 -16
package/package.json
CHANGED
|
@@ -2,4 +2,5 @@ export { default as isValid } from './isValid.js'
|
|
|
2
2
|
export { default as upload } from './upload.js'
|
|
3
3
|
export { default as syncFolder } from './syncFolder.js'
|
|
4
4
|
export { default as remove } from './remove.js'
|
|
5
|
+
export { default as previewRemoteUrl } from './previewRemoteUrl.js'
|
|
5
6
|
// export { default as uploadFolder } from './uploadFolder.js'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default async ({
|
|
2
|
+
filename,
|
|
3
|
+
auth,
|
|
4
|
+
// contentType = 'image/png'
|
|
5
|
+
}) => {
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const {
|
|
9
|
+
endPoint,
|
|
10
|
+
bucketName
|
|
11
|
+
} = auth
|
|
12
|
+
|
|
13
|
+
const url = `https://${endPoint}/${bucketName}/${filename}`
|
|
14
|
+
return { url }
|
|
15
|
+
|
|
16
|
+
} catch (e) {
|
|
17
|
+
console.error(e)
|
|
18
|
+
}
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
@@ -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),
|
package/src/project/index.js
CHANGED
|
@@ -16,27 +16,28 @@ export default async ({ child,
|
|
|
16
16
|
src: _url,
|
|
17
17
|
} } = child
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
//#region CACHE
|
|
20
20
|
let _activity = await getActivity({ path })
|
|
21
|
-
if (!settings.forceUploadAssets) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
21
|
+
// if (!settings.forceUploadAssets) {
|
|
22
|
+
// const codeActivity = _activity[entry.code]
|
|
23
|
+
// if (codeActivity) {
|
|
24
|
+
// const files = codeActivity.files
|
|
25
|
+
// if (files && files[_url]) {
|
|
26
|
+
// const cache = files[_url]
|
|
27
|
+
// return {
|
|
28
|
+
// ...child,
|
|
29
|
+
// properties: {
|
|
30
|
+
// ...child.properties,
|
|
31
|
+
// src: cache.url
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
37
|
+
//#endregion
|
|
37
38
|
|
|
38
39
|
let result
|
|
39
|
-
const destination =
|
|
40
|
+
const destination = buildPaths.email.assetsContainer
|
|
40
41
|
if (isLocal(_url)) {
|
|
41
42
|
result = await treatLocalFile({ url: _url, path, destination })
|
|
42
43
|
}
|
|
@@ -53,7 +54,7 @@ export default async ({ child,
|
|
|
53
54
|
uploadResult = await upload({
|
|
54
55
|
id: cloud.id,
|
|
55
56
|
sourceUrl,
|
|
56
|
-
filename: `${buildPaths.email.
|
|
57
|
+
filename: `${buildPaths.email.assetsContainerRemote}/${filename}`,
|
|
57
58
|
auth: cloud.auth,
|
|
58
59
|
settings
|
|
59
60
|
})
|
|
@@ -79,7 +80,6 @@ export default async ({ child,
|
|
|
79
80
|
content: _activity,
|
|
80
81
|
})
|
|
81
82
|
|
|
82
|
-
|
|
83
83
|
return {
|
|
84
84
|
...child,
|
|
85
85
|
properties: {
|
|
@@ -14,9 +14,7 @@ export default async (props) => {
|
|
|
14
14
|
buildPaths
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
// let md = await mdastToMarkdown({ mdast })
|
|
18
17
|
let body = hastToHtml({ data: _hast })
|
|
19
|
-
// await fs.promises.writeFile(`${path}/.build/html/email.cloud.html`, html)
|
|
20
18
|
|
|
21
19
|
await fs.promises.writeFile(
|
|
22
20
|
buildPaths.email.body,
|
|
@@ -7,12 +7,11 @@ export default async (props) => {
|
|
|
7
7
|
const { entry } = props
|
|
8
8
|
const { path, email: { hast }, buildPaths } = entry
|
|
9
9
|
|
|
10
|
-
const destination = `${path}/.assets`
|
|
11
|
-
await ensureDirectoryExists(destination, false)
|
|
12
10
|
|
|
13
11
|
const _hast = await perform({
|
|
14
12
|
child: hast,
|
|
15
13
|
path,
|
|
14
|
+
buildPaths
|
|
16
15
|
|
|
17
16
|
})
|
|
18
17
|
|
|
@@ -36,7 +35,7 @@ export default async (props) => {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
const perform = async (props) => {
|
|
39
|
-
const { child, path } = props
|
|
38
|
+
const { child, path, buildPaths } = props
|
|
40
39
|
let _child = { ...child }
|
|
41
40
|
|
|
42
41
|
if (child.properties && child.properties.dataNotifilesDoNotConsolidate) {
|
|
@@ -47,7 +46,8 @@ const perform = async (props) => {
|
|
|
47
46
|
case 'img': {
|
|
48
47
|
_child = await treatImage({
|
|
49
48
|
child: _child,
|
|
50
|
-
path
|
|
49
|
+
path,
|
|
50
|
+
buildPaths
|
|
51
51
|
})
|
|
52
52
|
} break
|
|
53
53
|
default:
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import isLocal from 'is-local'
|
|
2
2
|
import treatLocalFile from './treatLocalFile.js'
|
|
3
3
|
import treatRemoteFile from './treatRemoteFile.js'
|
|
4
|
+
import ensureDirectoryExists from '../../../../lib/fs/ensureDirectoryExists.js'
|
|
4
5
|
|
|
5
6
|
export default async ({ child,
|
|
6
|
-
path,
|
|
7
|
+
path, buildPaths }) => {
|
|
7
8
|
const { properties: {
|
|
8
9
|
src: url,
|
|
9
10
|
} } = child
|
|
10
11
|
|
|
11
12
|
let result
|
|
12
|
-
const destination =
|
|
13
|
+
const destination = buildPaths.email.assetsContainer
|
|
14
|
+
await ensureDirectoryExists(destination)
|
|
13
15
|
|
|
14
16
|
if (isLocal(url)) {
|
|
15
17
|
if (url.indexOf(destination) !== 0) {
|
|
@@ -23,7 +25,8 @@ export default async ({ child,
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
let filename = result.filename
|
|
26
|
-
const newUrl = `.assets/${filename}`
|
|
28
|
+
// const newUrl = `.assets/${filename}`
|
|
29
|
+
const newUrl = result.path
|
|
27
30
|
return {
|
|
28
31
|
...child,
|
|
29
32
|
properties: {
|
|
@@ -29,7 +29,8 @@ export default async ({
|
|
|
29
29
|
textFileName: `${entry.slug}/email/${code}/text.txt`,
|
|
30
30
|
subject: `${path}/.build/email/${code}/subject.txt`,
|
|
31
31
|
subjectFileName: `${entry.slug}/email/${code}/subject.txt`,
|
|
32
|
-
assetsContainer: `${
|
|
32
|
+
assetsContainer: `${path}/.build/email/${code}/assets`,
|
|
33
|
+
assetsContainerRemote: `${entry.slug}/email/${code}/assets`,
|
|
33
34
|
attachmentsContainer: `${entry.slug}/email/${code}/attachments`,
|
|
34
35
|
manifestFileNameBuilt: `${path}/.build/email/${code}/manifest.json`,
|
|
35
36
|
manifestFileName: `${entry.slug}/email/${code}/manifest.json`,
|
|
@@ -39,7 +40,8 @@ export default async ({
|
|
|
39
40
|
containerRemote: `${entry.slug}/textmessage/${code}`,
|
|
40
41
|
text: `${path}/.build/textmessage/${code}/textmessage.txt`,
|
|
41
42
|
textFileName: `${entry.slug}/textmessage/${code}/textmessage.txt`,
|
|
42
|
-
assetsContainer: `${
|
|
43
|
+
assetsContainer: `${path}/.build/textmessage/${code}/assets`,
|
|
44
|
+
assetsContainerRemote: `${entry.slug}/textmessage/${code}/assets`,
|
|
43
45
|
manifestFileNameBuilt: `${path}/.build/textmessage/${code}/manifest.json`,
|
|
44
46
|
manifestFileName: `${entry.slug}/textmessage/${code}/manifest.json`,
|
|
45
47
|
},
|
|
@@ -48,7 +50,8 @@ export default async ({
|
|
|
48
50
|
containerRemote: `${entry.slug}/pushnotification/${code}`,
|
|
49
51
|
text: `${path}/.build/pushnotification/${code}/pushnotification.txt`,
|
|
50
52
|
textFileName: `${entry.slug}/pushnotification/${code}/pushnotification.txt`,
|
|
51
|
-
assetsContainer: `${
|
|
53
|
+
assetsContainer: `${path}/.build/pushnotification/${code}/assets`,
|
|
54
|
+
assetsContainerRemote: `${entry.slug}/pushnotification/${code}/assets`,
|
|
52
55
|
manifestFileNameBuilt: `${path}/.build/pushnotification/${code}/manifest.json`,
|
|
53
56
|
manifestFileName: `${entry.slug}/pushnotification/${code}/manifest.json`,
|
|
54
57
|
},
|
|
@@ -5,7 +5,9 @@ import importJSONAsync from '../../../lib/fs/importJSONAsync.js'
|
|
|
5
5
|
|
|
6
6
|
export default async ({
|
|
7
7
|
path,
|
|
8
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import fsPath from 'path'
|
|
2
2
|
import checkFileExists from '../../../lib/fs/checkFileExists.js'
|
|
3
|
-
import
|
|
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, "
|
|
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
|
-
|
|
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
|
|
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.
|
|
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
|
|
22
|
-
|
|
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
|
-
|
|
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,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
|
-
|
|
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
|
|
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
|
|
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
|
|
10
|
-
platforms = [],
|
|
11
|
-
status = "draft",
|
|
12
|
-
canonicalUrl = "",
|
|
15
|
+
title = "My new template",
|
|
13
16
|
tags,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
force = false
|
|
17
|
+
i18n = {},
|
|
18
|
+
force = false,
|
|
19
|
+
emailType = 'mastered'
|
|
19
20
|
}) => {
|
|
20
21
|
try {
|
|
21
|
-
const
|
|
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}
|
|
32
|
-
|
|
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
|
|
54
|
-
const
|
|
55
|
-
await fs.promises.writeFile(
|
|
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
|
|
58
|
-
const
|
|
59
|
-
await fs.promises.writeFile(
|
|
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
|
|
2
|
+
test('creates a new post', async () => {
|
|
3
3
|
const fsPath = (await import('path')).default
|
|
4
|
-
let path = fsPath.resolve(
|
|
5
|
-
const operation = (await import('./
|
|
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
|
|
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
|
+
}
|
|
@@ -8,7 +8,8 @@ export default async (props) => {
|
|
|
8
8
|
|
|
9
9
|
let _hast = await perform({
|
|
10
10
|
child: hast,
|
|
11
|
-
path
|
|
11
|
+
path,
|
|
12
|
+
buildPaths
|
|
12
13
|
})
|
|
13
14
|
|
|
14
15
|
let body = hastToHtml({ data: _hast })
|
|
@@ -31,7 +32,7 @@ export default async (props) => {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const perform = async (props) => {
|
|
34
|
-
const { child, path } = props
|
|
35
|
+
const { child, path, buildPaths } = props
|
|
35
36
|
let _child = { ...child }
|
|
36
37
|
|
|
37
38
|
if (child.properties && _child.properties.dataNotifilesDoNotOptimize) {
|
|
@@ -42,7 +43,8 @@ const perform = async (props) => {
|
|
|
42
43
|
case 'img': {
|
|
43
44
|
_child = await treatImage({
|
|
44
45
|
child: _child,
|
|
45
|
-
path
|
|
46
|
+
path,
|
|
47
|
+
buildPaths
|
|
46
48
|
})
|
|
47
49
|
} break
|
|
48
50
|
default:
|
|
@@ -2,9 +2,10 @@ import fsPath from 'path'
|
|
|
2
2
|
import isLocal from 'is-local'
|
|
3
3
|
import isRelative from 'is-relative'
|
|
4
4
|
import sharp from 'sharp'
|
|
5
|
+
import fs from 'fs'
|
|
5
6
|
|
|
6
7
|
export default async ({ child,
|
|
7
|
-
path, }) => {
|
|
8
|
+
path, buildPaths }) => {
|
|
8
9
|
const { properties: {
|
|
9
10
|
src: url,
|
|
10
11
|
} } = child
|
|
@@ -22,14 +23,17 @@ export default async ({ child,
|
|
|
22
23
|
default: break
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
const filename =
|
|
26
|
-
const destination = `${
|
|
26
|
+
const filename = `${fsPath.parse(sourceUrl).name}_optimized.webp`
|
|
27
|
+
const destination = `${buildPaths.email.assetsContainer}/${filename}`
|
|
27
28
|
|
|
28
29
|
await sharp(sourceUrl)
|
|
29
30
|
.webp({ quality: 90 })
|
|
30
31
|
.toFile(destination)
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
await fs.promises.rm(sourceUrl)
|
|
34
|
+
|
|
35
|
+
// const newUrl = `assets/${filename}`
|
|
36
|
+
const newUrl = destination
|
|
33
37
|
return {
|
|
34
38
|
...child,
|
|
35
39
|
properties: {
|
|
@@ -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 (
|
|
38
|
-
|
|
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
|
package/src/project/new/index.js
DELETED
package/src/project/new/plain.js
DELETED
|
@@ -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,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
|
-
|