@fullstackunicorn/create-root 1.0.23 → 1.0.25
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/assets/root.fullstackunicorn.dev/assets/index.def.js +32 -4
- package/assets/root.fullstackunicorn.dev/assets/modules/sync.js +164 -302
- package/assets/root.fullstackunicorn.dev/assets/modules/sync.tools.js +39 -6
- package/assets/root.fullstackunicorn.dev/assets/package.md +9 -2
- package/assets/root.fullstackunicorn.dev/assets/webapp.runner.js +42 -1
- package/assets/root.fullstackunicorn.dev/frontend/base/account/AccountCard.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/base/cookies/@use.js +5 -93
- package/assets/root.fullstackunicorn.dev/frontend/base/cookies/CookiesCard.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/base/language/@use.js +4 -69
- package/assets/root.fullstackunicorn.dev/frontend/base/language/LanguageCard.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/base/layout/Layout.pod.js +2 -2
- package/assets/root.fullstackunicorn.dev/frontend/base/legals/LegalCard.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/base/legals/LegalsCard.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/base/resources/@use.js +15 -0
- package/assets/root.fullstackunicorn.dev/frontend/base/router/@use.js +2 -1
- package/assets/root.fullstackunicorn.dev/frontend/base/theme/ThemeCard.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/config.style.js +21 -9
- package/assets/root.fullstackunicorn.dev/frontend/features/legal/Legal.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/imports/animated/Root.js +4 -8
- package/assets/root.fullstackunicorn.dev/frontend/imports/core/Scrollable.js +7 -2
- package/assets/root.fullstackunicorn.dev/frontend/imports/core/Viewport.js +29 -0
- package/assets/root.fullstackunicorn.dev/frontend/imports/head/Head.js +16 -26
- package/assets/root.fullstackunicorn.dev/frontend/modals/cookies/cookies.api.js +25 -0
- package/assets/root.fullstackunicorn.dev/frontend/modals/cookies/cookies.js +88 -0
- package/assets/root.fullstackunicorn.dev/frontend/modals/countries/countries.api.js +22 -0
- package/assets/root.fullstackunicorn.dev/frontend/modals/countries/countries.js +58 -37
- package/assets/root.fullstackunicorn.dev/frontend/modals/languages/languages.api.js +23 -0
- package/assets/root.fullstackunicorn.dev/frontend/modals/languages/languages.js +81 -0
- package/assets/root.fullstackunicorn.dev/frontend/modules/base/Bottom.js +10 -0
- package/assets/root.fullstackunicorn.dev/frontend/{panels/layout → modules/base}/Bottom.pod.js +1 -4
- package/assets/root.fullstackunicorn.dev/frontend/modules/base/ComingSoon.js +7 -0
- package/assets/root.fullstackunicorn.dev/frontend/modules/base/ComingSoon.pod.js +17 -0
- package/assets/root.fullstackunicorn.dev/frontend/{panels/error → modules/base}/ErrorPage.js +4 -4
- package/assets/root.fullstackunicorn.dev/frontend/{panels/error → modules/base}/ErrorPage.pod.js +7 -7
- package/assets/root.fullstackunicorn.dev/frontend/{panels/layout → modules/base}/PageTitle.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/{panels/layout → modules/base}/PageTitle.pod.js +4 -6
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/cards/Account.js +9 -8
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/cards/Account.pod.js +28 -18
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/cards/Launcher.js +4 -4
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/cards/Launcher.pod.js +10 -11
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/cards/Linker.js +4 -4
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/cards/Linker.pod.js +11 -12
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/cards/Slider.js +8 -7
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/cards/Slider.pod.js +14 -14
- package/assets/root.fullstackunicorn.dev/frontend/{panels/wrapper/fixed → modules/layout}/Wrapper.js +2 -2
- package/assets/root.fullstackunicorn.dev/frontend/{panels/wrapper/fixed → modules/layout}/Wrapper.pod.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/{panels/selectors/actions → modules/modals/select}/Actions.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/{panels/selectors → modules/modals}/select/SelectPage.js +2 -2
- package/assets/root.fullstackunicorn.dev/frontend/{panels/sliders → modules/modals}/slider/SliderPage.js +2 -2
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/page/PageScrollable.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/modules/page/PageScrollable.pod.js +23 -0
- package/assets/root.fullstackunicorn.dev/frontend/modules/prose/@runs.js +52 -0
- package/assets/root.fullstackunicorn.dev/frontend/modules/prose/Prose.js +56 -0
- package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/prose/Prose.pod.js +2 -14
- package/assets/root.fullstackunicorn.dev/frontend/pages/@use.js +26 -11
- package/assets/root.fullstackunicorn.dev/frontend/pages/root/Callout.api.js +9 -25
- package/assets/root.fullstackunicorn.dev/frontend/pages/root/Callout.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/pages/root/Legal.api.js +16 -24
- package/assets/root.fullstackunicorn.dev/frontend/pages/root/Legal.js +2 -2
- package/assets/root.fullstackunicorn.dev/frontend/pages/root/Legals.api.js +14 -8
- package/assets/root.fullstackunicorn.dev/frontend/pages/root/Legals.js +5 -5
- package/assets/root.fullstackunicorn.dev/frontend/pages/root/User.api.js +8 -11
- package/assets/root.fullstackunicorn.dev/frontend/pages/root/User.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/pages/{app → scope}/Checkout.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/pages/scope/Home.abs.js +18 -0
- package/assets/root.fullstackunicorn.dev/frontend/pages/scope/Home.api.js +15 -0
- package/assets/root.fullstackunicorn.dev/frontend/pages/scope/Home.js +24 -0
- package/assets/root.fullstackunicorn.dev/frontend/panels/{slider/Slider.js → slideshows/Slideshow.js} +34 -20
- package/assets/root.fullstackunicorn.dev/frontend/panels/slideshows/Slideshow.map.js +27 -0
- package/assets/root.fullstackunicorn.dev/frontend/panels/slideshows/Slideshow.md +90 -0
- package/assets/root.fullstackunicorn.dev/frontend/panels/{slider/Slider.pod.js → slideshows/Slideshow.pod.js} +14 -28
- package/assets/root.fullstackunicorn.dev/frontend/preloader/@use.js +4 -5
- package/assets/root.fullstackunicorn.dev/frontend/root/errors.root.js +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/root/modals.root.js +8 -8
- package/assets/root.fullstackunicorn.dev/frontend/root/pages.scope.js +2 -2
- package/assets/root.fullstackunicorn.dev/frontend/root/preload.scope.js +1 -1
- package/assets/root.fullstackunicorn.dev/package.json +1 -1
- package/assets/root.fullstackunicorn.dev/workspace/config/tabulars_data_content/config/import.json +4 -26
- package/assets/root.fullstackunicorn.dev/workspace/config/tabulars_data_content/objs/A01.metadata.meta.json +72 -79
- package/assets/root.fullstackunicorn.dev/workspace/config/tabulars_data_content/objs/C01.home.data.json +25 -5
- package/assets/root.fullstackunicorn.dev/workspace/volume/data/lookups/cookies/en-US.json +3 -19
- package/assets/root.fullstackunicorn.dev/workspace/volume/data/lookups/cookies/it-IT.json +6 -22
- package/assets/root.fullstackunicorn.dev/workspace/volume/data/root/user/en-US.json +4 -6
- package/assets/root.fullstackunicorn.dev/workspace/volume/data/root/user/it-IT.json +5 -19
- package/package.json +1 -1
- package/assets/root.fullstackunicorn.dev/frontend/pages/app/Home.abs.js +0 -11
- package/assets/root.fullstackunicorn.dev/frontend/pages/app/Home.api.js +0 -18
- package/assets/root.fullstackunicorn.dev/frontend/pages/app/Home.js +0 -23
- package/assets/root.fullstackunicorn.dev/frontend/panels/card/book/BookCard.js +0 -58
- package/assets/root.fullstackunicorn.dev/frontend/panels/card/book/BookCard.pod.js +0 -37
- package/assets/root.fullstackunicorn.dev/frontend/panels/card/book/BookProse.js +0 -22
- package/assets/root.fullstackunicorn.dev/frontend/panels/grid/book/Grid.js +0 -115
- package/assets/root.fullstackunicorn.dev/frontend/panels/grid/book/Grid.pod.js +0 -65
- package/assets/root.fullstackunicorn.dev/frontend/panels/grid/book/Item.js +0 -3
- package/assets/root.fullstackunicorn.dev/frontend/panels/grid/book/Item.pod.js +0 -50
- package/assets/root.fullstackunicorn.dev/frontend/panels/layout/Bottom.js +0 -12
- package/assets/root.fullstackunicorn.dev/frontend/panels/page/PageScrollable.pod.js +0 -85
- package/assets/root.fullstackunicorn.dev/frontend/panels/prose/@use.js +0 -21
- package/assets/root.fullstackunicorn.dev/frontend/panels/prose/Prose.js +0 -84
- package/assets/root.fullstackunicorn.dev/frontend/panels/selectors/popup/PopupModal.js +0 -54
- package/assets/root.fullstackunicorn.dev/frontend/panels/selectors/select/SelectModal.js +0 -52
- package/assets/root.fullstackunicorn.dev/frontend/panels/shopper/bookstore/Buy.js +0 -19
- package/assets/root.fullstackunicorn.dev/frontend/panels/shopper/bookstore/Buy.pod.js +0 -17
- package/assets/root.fullstackunicorn.dev/frontend/panels/shopper/bookstore/Shopper.js +0 -39
- package/assets/root.fullstackunicorn.dev/frontend/panels/shopper/bookstore/Shopper.pod.js +0 -187
- package/assets/root.fullstackunicorn.dev/frontend/panels/sliders/slider/SliderModal.js +0 -39
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/selectors/actions → modules/modals/select}/Actions.pod.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/selectors → modules/modals}/select/SelectItem.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/selectors → modules/modals}/select/SelectItem.pod.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/selectors → modules/modals}/select/SelectPage.pod.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/selectors/actions → modules/modals/select}/SelectPicked.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/selectors/actions → modules/modals/select}/SelectPicked.pod.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/sliders/actions → modules/modals/slider}/Actions.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/sliders/actions → modules/modals/slider}/Actions.pod.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/sliders → modules/modals}/slider/SliderItem.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/sliders → modules/modals}/slider/SliderItem.pod.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels/sliders → modules/modals}/slider/SliderPage.pod.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/prose/@formatter.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/prose/Basic.js +0 -0
- /package/assets/root.fullstackunicorn.dev/frontend/{panels → modules}/prose/Basic.pod.js +0 -0
|
@@ -1,288 +1,218 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// export class Sync {
|
|
7
|
-
|
|
8
|
-
// constructor(init) {
|
|
9
|
-
|
|
10
|
-
// this.def = init.def
|
|
11
|
-
// this.tools = new Tools(init)
|
|
12
|
-
// this.local = new Local(init)
|
|
13
|
-
// }
|
|
14
|
-
|
|
15
|
-
// runConfig = async (target) => {
|
|
16
|
-
|
|
17
|
-
// this.def.spinner.start()
|
|
18
|
-
// this.def.reportConfig(`🔥🔥🔥 Sync.runConfig:start`)
|
|
19
|
-
|
|
20
|
-
// if (target) this.def.app.target = target
|
|
21
|
-
|
|
22
|
-
// try {
|
|
23
|
-
|
|
24
|
-
// const list = await this.tools.getList(this.def.folders.config)
|
|
25
|
-
|
|
26
|
-
// this.def.reportConfig(`✅ file-list-read ${this.def.folders.config}`)
|
|
27
|
-
|
|
28
|
-
// const zip = new JSZip()
|
|
29
|
-
// zip.file('app.json', JSON.stringify(app, null, 2))
|
|
30
|
-
|
|
31
|
-
// for (const relPath of list) {
|
|
32
|
-
// const buffer = await fsa.readFile(`${this.def.folders.config}/${relPath}`)
|
|
33
|
-
// zip.file(relPath, buffer)
|
|
34
|
-
// this.def.reportConfig(`✅ file-added-to-zip ${relPath}`)
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
// await fsa.safeRemove(this.def.files.export.configZip)
|
|
38
|
-
// await fsa.ensureFileDir(this.def.files.export.configZip)
|
|
39
|
-
// const bufferZip = await zip.generateAsync({ type: 'nodebuffer', compression: 'DEFLATE' })
|
|
40
|
-
// await fsa.writeFile(this.def.files.export.configZip, bufferZip)
|
|
41
|
-
|
|
42
|
-
// this.def.reportConfig(`✅ written-zip \n💾 ${this.def.files.export.configZip}`)
|
|
43
|
-
|
|
44
|
-
// const payload = {}
|
|
45
|
-
// payload.crypto = crypto
|
|
46
|
-
// payload.fileEndpoint = this.def.endpoints.file
|
|
47
|
-
// payload.chunkEndpoint = this.def.endpoints.chunk
|
|
48
|
-
// payload.statusEndpoint = this.def.endpoints.status
|
|
49
|
-
// payload.finalizeEndpoint = this.def.endpoints.finalize
|
|
50
|
-
// const sender = new Sender(payload)
|
|
1
|
+
import { app, fsa, axios, crypto, JSZip, Sender } from '#@/index.dep.js'
|
|
2
|
+
import { auth } from '#@/modules/sync.auth.js'
|
|
3
|
+
import { Local } from '#@/modules/sync.local.js'
|
|
4
|
+
import { Tools } from '#@/modules/sync.tools.js'
|
|
51
5
|
|
|
52
|
-
|
|
53
|
-
// upload.bytes = bufferZip
|
|
54
|
-
// upload.target = this.def.app.target
|
|
55
|
-
// upload.token = await auth.getToken()
|
|
56
|
-
// upload.payload = {}
|
|
57
|
-
// upload.payload.callback = 'configure'
|
|
58
|
-
// upload.payload.clientId = this.def.app.clientId
|
|
6
|
+
export class Sync {
|
|
59
7
|
|
|
60
|
-
|
|
8
|
+
constructor(init) {
|
|
61
9
|
|
|
62
|
-
|
|
10
|
+
this.def = init.def
|
|
11
|
+
this.tools = new Tools(init)
|
|
12
|
+
this.local = new Local(init)
|
|
13
|
+
}
|
|
63
14
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
15
|
+
getWorkspaceApp = () => {
|
|
16
|
+
const text = JSON.stringify(app, null, 2)
|
|
17
|
+
const buffer = Buffer.from(text, 'utf8')
|
|
18
|
+
const hash = this.tools.hash(buffer)
|
|
19
|
+
return {
|
|
20
|
+
relPath: 'config/app.json',
|
|
21
|
+
text,
|
|
22
|
+
buffer,
|
|
23
|
+
hash
|
|
24
|
+
}
|
|
25
|
+
}
|
|
67
26
|
|
|
68
|
-
|
|
69
|
-
// else this.def.writeConfig(target, `❌❌❌ Sync.runConfig:failed`)
|
|
27
|
+
runWorkspacePush = async (target) => {
|
|
70
28
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// F3.catch.throw(e)
|
|
74
|
-
// }
|
|
29
|
+
this.def.spinner.start()
|
|
30
|
+
this.def.reportWorkspace(`🔥🔥🔥 Sync.runWorkspacePush:start`)
|
|
75
31
|
|
|
76
|
-
|
|
32
|
+
if (target) this.def.app.target = target
|
|
77
33
|
|
|
78
|
-
|
|
34
|
+
try {
|
|
79
35
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
36
|
+
const headers = {}
|
|
37
|
+
headers.Authorization = await auth.getToken()
|
|
38
|
+
this.def.reportWorkspace(`✅ workspace-token-obtained`)
|
|
83
39
|
|
|
84
|
-
|
|
40
|
+
const dataPush = {}
|
|
41
|
+
dataPush.clientId = this.def.app.clientId
|
|
42
|
+
dataPush.target = this.def.app.target
|
|
43
|
+
dataPush.manifest = await this.tools.getWorkspaceManifest()
|
|
44
|
+
const workspaceApp = this.getWorkspaceApp()
|
|
45
|
+
dataPush.manifest.files[workspaceApp.relPath] = workspaceApp.hash
|
|
46
|
+
dataPush.manifest.total = Object.keys(dataPush.manifest.files).length
|
|
47
|
+
this.def.reportWorkspace(`✅ workspace-manifest-created`)
|
|
85
48
|
|
|
86
|
-
|
|
87
|
-
// headers.Authorization = await auth.getToken()
|
|
88
|
-
// this.def.reportAssets(`✅ plan-token-obtained`)
|
|
49
|
+
this.def.reportWorkspace(`🛜 Send-workspace-push ${this.def.endpoints.workspacePush}`)
|
|
89
50
|
|
|
90
|
-
|
|
91
|
-
// dataPlan.clientId = this.def.app.clientId
|
|
92
|
-
// dataPlan.target = this.def.app.target
|
|
93
|
-
// dataPlan.manifest = await this.tools.getManifest()
|
|
94
|
-
// this.def.reportAssets(`✅ plan-manifest-created`)
|
|
51
|
+
const response = await axios.post(this.def.endpoints.workspacePush, dataPush, { headers })
|
|
95
52
|
|
|
96
|
-
|
|
53
|
+
this.def.reportWorkspace(`🛜 Send-workspace-push-report-start`)
|
|
54
|
+
this.def.reportWorkspace(`🛜 ${response?.data?.report.join('\n🛜 ')}`)
|
|
55
|
+
this.def.reportWorkspace(`🛜 Send-workspace-push-report-end`)
|
|
97
56
|
|
|
98
|
-
|
|
57
|
+
const plan = response?.data?.plan
|
|
58
|
+
if (!F3.obj.isGood(plan)) F3.throw(`missing-workspace-plan`)
|
|
99
59
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
60
|
+
await fsa.ensureFileDir(this.def.files.export.manifest)
|
|
61
|
+
await fsa.writeJSON(this.def.files.export.manifest, dataPush.manifest)
|
|
62
|
+
this.def.reportWorkspace(`✅ written-workspace-manifest \n💾 ${this.def.files.export.manifest}`)
|
|
103
63
|
|
|
104
|
-
|
|
105
|
-
|
|
64
|
+
await fsa.ensureFileDir(this.def.files.export.plan)
|
|
65
|
+
await fsa.writeJSON(this.def.files.export.plan, plan)
|
|
66
|
+
this.def.reportWorkspace(`✅ written-workspace-plan \n💾 ${this.def.files.export.plan}`)
|
|
106
67
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
68
|
+
if (plan.isAlreadyInSync) {
|
|
69
|
+
this.def.writeWorkspace(target, `🔥🔥🔥 Sync.runWorkspacePush:success-already-in-sync`)
|
|
70
|
+
return true
|
|
71
|
+
}
|
|
110
72
|
|
|
111
|
-
|
|
112
|
-
// await fsa.writeJSON(this.def.files.export.plan, plan)
|
|
113
|
-
// this.def.reportAssets(`✅ written-manifest-plan-response \n💾 ${this.def.files.export.plan}`)
|
|
73
|
+
const uploadPaths = Object.keys(F3.obj.safe(plan.upload))
|
|
114
74
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
75
|
+
if (!uploadPaths.length) {
|
|
76
|
+
this.def.writeWorkspace(target, `🔥🔥🔥 Sync.runWorkspacePush:success-manifest-only`)
|
|
77
|
+
return true
|
|
78
|
+
}
|
|
119
79
|
|
|
120
|
-
|
|
121
|
-
// const zip = new JSZip()
|
|
80
|
+
const zip = new JSZip()
|
|
122
81
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// const buffer = await fsa.readFile(fullPath)
|
|
126
|
-
// if (!buffer) F3.throw(`zip-missing-file:${relPath}`)
|
|
127
|
-
// zip.file(relPath, buffer)
|
|
128
|
-
// this.def.reportAssets(`✅ file-added-to-zip ${relPath}`)
|
|
129
|
-
// }
|
|
82
|
+
for (const relPath of uploadPaths) {
|
|
83
|
+
let buffer = null
|
|
130
84
|
|
|
131
|
-
|
|
132
|
-
|
|
85
|
+
if (relPath === workspaceApp.relPath) buffer = workspaceApp.buffer
|
|
86
|
+
else {
|
|
87
|
+
const fullPath = `${this.def.workspace}/${relPath}`
|
|
88
|
+
buffer = await fsa.readFile(fullPath)
|
|
89
|
+
}
|
|
133
90
|
|
|
134
|
-
|
|
135
|
-
|
|
91
|
+
if (!buffer) F3.throw(`workspace-zip-missing-file:${relPath}`)
|
|
92
|
+
zip.file(relPath, buffer)
|
|
93
|
+
this.def.reportWorkspace(`✅ ➕ zip ${relPath}`)
|
|
94
|
+
}
|
|
136
95
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
96
|
+
await fsa.safeRemove(this.def.files.export.workspaceZip)
|
|
97
|
+
await fsa.ensureFileDir(this.def.files.export.workspaceZip)
|
|
98
|
+
const bufferZip = await zip.generateAsync({ type: 'nodebuffer', compression: 'DEFLATE' })
|
|
99
|
+
await fsa.writeFile(this.def.files.export.workspaceZip, bufferZip)
|
|
140
100
|
|
|
141
|
-
|
|
142
|
-
// initSender.crypto = crypto
|
|
143
|
-
// initSender.fileEndpoint = this.def.endpoints.file
|
|
144
|
-
// initSender.chunkEndpoint = this.def.endpoints.chunk
|
|
145
|
-
// initSender.statusEndpoint = this.def.endpoints.status
|
|
146
|
-
// initSender.finalizeEndpoint = this.def.endpoints.finalize
|
|
147
|
-
// const sender = new Sender(initSender)
|
|
101
|
+
this.def.reportWorkspace(`✅ written-workspace-zip \n💾 ${this.def.files.export.workspaceZip}`)
|
|
148
102
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// argsUpload.payload.clientId = this.def.app.clientId
|
|
103
|
+
const payload = {}
|
|
104
|
+
payload.crypto = crypto
|
|
105
|
+
payload.fileEndpoint = this.def.endpoints.file
|
|
106
|
+
payload.chunkEndpoint = this.def.endpoints.chunk
|
|
107
|
+
payload.statusEndpoint = this.def.endpoints.status
|
|
108
|
+
payload.finalizeEndpoint = this.def.endpoints.finalize
|
|
109
|
+
const sender = new Sender(payload)
|
|
157
110
|
|
|
158
|
-
|
|
111
|
+
const upload = {}
|
|
112
|
+
upload.bytes = bufferZip
|
|
113
|
+
upload.target = this.def.app.target
|
|
114
|
+
upload.token = await auth.getToken()
|
|
115
|
+
upload.payload = {}
|
|
116
|
+
upload.payload.callback = 'workspace'
|
|
117
|
+
upload.payload.importId = plan.importId
|
|
118
|
+
upload.payload.clientId = this.def.app.clientId
|
|
159
119
|
|
|
160
|
-
|
|
120
|
+
this.def.reportWorkspace(`🛜 Send-workspace-zip ${this.def.endpoints.file}`)
|
|
161
121
|
|
|
162
|
-
|
|
163
|
-
// this.def.reportAssets(`🛜 ${senderRes?.callback?.report.join('\n🛜 ')}`)
|
|
164
|
-
// this.def.reportAssets(`🛜 Send-assets-zip-report-end`)
|
|
122
|
+
const senderRes = await sender.upload(upload)
|
|
165
123
|
|
|
166
|
-
|
|
167
|
-
|
|
124
|
+
this.def.reportWorkspace(`🛜 Send-workspace-zip-report-start`)
|
|
125
|
+
this.def.reportWorkspace(`🛜 ${senderRes?.callback?.report.join('\n🛜 ')}`)
|
|
126
|
+
this.def.reportWorkspace(`🛜 Send-workspace-zip-report-end`)
|
|
168
127
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// F3.catch.throw(e)
|
|
172
|
-
// }
|
|
128
|
+
if (senderRes?.callback?.isOk) this.def.writeWorkspace(target, `🔥🔥🔥 Sync.runWorkspacePush:success`)
|
|
129
|
+
else this.def.writeWorkspace(target, `❌❌❌ Sync.runWorkspacePush:failed`)
|
|
173
130
|
|
|
174
|
-
|
|
131
|
+
} catch (e) {
|
|
132
|
+
this.def.writeWorkspace(target, `❌❌❌ Sync.runWorkspacePush:error`)
|
|
133
|
+
F3.catch.throw(e)
|
|
134
|
+
}
|
|
175
135
|
|
|
176
|
-
|
|
136
|
+
}
|
|
177
137
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
138
|
+
runConfig = async (target) => {
|
|
139
|
+
return await this.runWorkspacePush(target)
|
|
140
|
+
}
|
|
181
141
|
|
|
182
|
-
|
|
142
|
+
runPush = async (target) => {
|
|
143
|
+
return await this.runWorkspacePush(target)
|
|
144
|
+
}
|
|
183
145
|
|
|
184
|
-
|
|
185
|
-
// payload.clientId = this.def.app.clientId
|
|
186
|
-
// payload.target = this.def.app.target
|
|
146
|
+
runWorkspacePull = async (target) => {
|
|
187
147
|
|
|
188
|
-
|
|
148
|
+
this.def.spinner.start()
|
|
149
|
+
this.def.reportWorkspace(`🔥🔥🔥 Sync.runWorkspacePull:start`)
|
|
189
150
|
|
|
190
|
-
|
|
151
|
+
if (target) this.def.app.target = target
|
|
191
152
|
|
|
192
|
-
|
|
153
|
+
try {
|
|
193
154
|
|
|
194
|
-
|
|
155
|
+
const headers = {}
|
|
156
|
+
headers.Authorization = await auth.getToken()
|
|
195
157
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
158
|
+
const payload = {}
|
|
159
|
+
payload.clientId = this.def.app.clientId
|
|
160
|
+
payload.target = this.def.app.target
|
|
199
161
|
|
|
200
|
-
|
|
201
|
-
// this.def.reportWorkers(`🛜 ${response?.data?.report.join('\n🛜 ')}`)
|
|
202
|
-
// this.def.reportWorkers(`🛜 Send-workers-report-end`)
|
|
162
|
+
this.def.reportWorkspace(`🛜 Send-workspace-pull ${this.def.endpoints.workspacePull}`)
|
|
203
163
|
|
|
204
|
-
|
|
205
|
-
|
|
164
|
+
const response = await axios.post(this.def.endpoints.workspacePull, payload, {
|
|
165
|
+
headers,
|
|
166
|
+
responseType: 'arraybuffer'
|
|
167
|
+
})
|
|
206
168
|
|
|
207
|
-
|
|
208
|
-
// this.def.writeWorkers(target, `❌❌❌ Sync.runWorkers:error`)
|
|
209
|
-
// F3.catch.throw(e)
|
|
210
|
-
// }
|
|
211
|
-
// }
|
|
212
|
-
// }
|
|
169
|
+
const filePath = this.def.getPullFile(this.def.app.target)
|
|
213
170
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
import { Local } from '#@/modules/sync.local.js'
|
|
217
|
-
import { Tools } from '#@/modules/sync.tools.js'
|
|
171
|
+
await fsa.ensureFileDir(filePath)
|
|
172
|
+
await fsa.writeFile(filePath, response.data)
|
|
218
173
|
|
|
219
|
-
|
|
174
|
+
this.def.reportWorkspace(`✅ 💾 workspace-pull-written ${filePath}`)
|
|
175
|
+
this.def.writeWorkspace(target, `🔥🔥🔥 Sync.runWorkspacePull:success`)
|
|
220
176
|
|
|
221
|
-
|
|
177
|
+
return true
|
|
222
178
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
179
|
+
} catch (e) {
|
|
180
|
+
this.def.writeWorkspace(target, `❌❌❌ Sync.runWorkspacePull:error`)
|
|
181
|
+
F3.catch.throw(e)
|
|
182
|
+
}
|
|
226
183
|
}
|
|
227
184
|
|
|
228
|
-
|
|
185
|
+
runCleanup = async (kind = 'workspace') => {
|
|
229
186
|
|
|
230
187
|
this.def.spinner.start()
|
|
231
|
-
this.def.
|
|
232
|
-
|
|
233
|
-
if (target) this.def.app.target = target
|
|
188
|
+
this.def.reportWorkspace(`🔥🔥🔥 Sync.runCleanup:start ${kind}`)
|
|
234
189
|
|
|
235
190
|
try {
|
|
236
191
|
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
this.def.reportConfig(`✅ file-list-read ${this.def.folders.config}`)
|
|
240
|
-
|
|
241
|
-
const zip = new JSZip()
|
|
242
|
-
zip.file('app.json', JSON.stringify(app, null, 2))
|
|
243
|
-
|
|
244
|
-
for (const relPath of list) {
|
|
245
|
-
const buffer = await fsa.readFile(`${this.def.folders.config}/${relPath}`)
|
|
246
|
-
zip.file(relPath, buffer)
|
|
247
|
-
this.def.reportConfig(`✅ file-added-to-zip ${relPath}`)
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
await fsa.safeRemove(this.def.files.export.configZip)
|
|
251
|
-
await fsa.ensureFileDir(this.def.files.export.configZip)
|
|
252
|
-
const bufferZip = await zip.generateAsync({ type: 'nodebuffer', compression: 'DEFLATE' })
|
|
253
|
-
await fsa.writeFile(this.def.files.export.configZip, bufferZip)
|
|
254
|
-
|
|
255
|
-
this.def.reportConfig(`✅ written-zip \n💾 ${this.def.files.export.configZip}`)
|
|
192
|
+
const headers = {}
|
|
193
|
+
headers.Authorization = await auth.getToken()
|
|
256
194
|
|
|
257
195
|
const payload = {}
|
|
258
|
-
payload.
|
|
259
|
-
payload.
|
|
260
|
-
payload.chunkEndpoint = this.def.endpoints.chunk
|
|
261
|
-
payload.statusEndpoint = this.def.endpoints.status
|
|
262
|
-
payload.finalizeEndpoint = this.def.endpoints.finalize
|
|
263
|
-
const sender = new Sender(payload)
|
|
196
|
+
payload.clientId = this.def.app.clientId
|
|
197
|
+
payload.kind = kind
|
|
264
198
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
upload.token = await auth.getToken()
|
|
269
|
-
upload.payload = {}
|
|
270
|
-
upload.payload.callback = 'configure'
|
|
271
|
-
upload.payload.clientId = this.def.app.clientId
|
|
199
|
+
this.def.reportWorkspace(`🛜 Send-workspace-cleanup ${this.def.endpoints.workspaceCleanup}`)
|
|
200
|
+
|
|
201
|
+
const response = await axios.post(this.def.endpoints.workspaceCleanup, payload, { headers })
|
|
272
202
|
|
|
273
|
-
|
|
203
|
+
const report = F3.arr.safe(response?.data?.report)
|
|
204
|
+
if (report.length) {
|
|
205
|
+
this.def.reportWorkspace(`🛜 ${report.join('\n🛜 ')}`)
|
|
206
|
+
}
|
|
274
207
|
|
|
275
|
-
|
|
208
|
+
if (!response?.data?.isOk) F3.throw(`workspace-cleanup-failed:${kind}`)
|
|
276
209
|
|
|
277
|
-
this.def.
|
|
278
|
-
this.def.reportConfig(`🛜 ${response?.callback?.report.join('\n🛜 ')}`)
|
|
279
|
-
this.def.reportConfig(`🛜 Send-request-report-end`)
|
|
210
|
+
this.def.writeWorkspace('local', `🔥🔥🔥 Sync.runCleanup:success ${kind}`)
|
|
280
211
|
|
|
281
|
-
|
|
282
|
-
else this.def.writeConfig(target, `❌❌❌ Sync.runConfig:failed`)
|
|
212
|
+
return true
|
|
283
213
|
|
|
284
214
|
} catch (e) {
|
|
285
|
-
this.def.
|
|
215
|
+
this.def.writeWorkspace('local', `❌❌❌ Sync.runCleanup:error ${kind}`)
|
|
286
216
|
F3.catch.throw(e)
|
|
287
217
|
}
|
|
288
218
|
|
|
@@ -296,87 +226,19 @@ export class Sync {
|
|
|
296
226
|
|
|
297
227
|
try {
|
|
298
228
|
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
this.def.
|
|
302
|
-
|
|
303
|
-
const dataPlan = {}
|
|
304
|
-
dataPlan.clientId = this.def.app.clientId
|
|
305
|
-
dataPlan.target = this.def.app.target
|
|
306
|
-
dataPlan.manifest = await this.tools.getManifest()
|
|
307
|
-
this.def.reportAssets(`✅ plan-manifest-created`)
|
|
229
|
+
const payload = {}
|
|
230
|
+
payload.clientId = this.def.app.clientId
|
|
231
|
+
payload.target = this.def.app.target
|
|
308
232
|
|
|
309
|
-
this.def.reportAssets(`🛜 Send-
|
|
233
|
+
this.def.reportAssets(`🛜 Send-assets ${this.def.endpoints.assets}`)
|
|
310
234
|
|
|
311
|
-
const response = await axios.post(this.def.endpoints.
|
|
235
|
+
const response = await axios.post(this.def.endpoints.assets, payload)
|
|
312
236
|
|
|
313
|
-
this.def.reportAssets(`🛜 Send-
|
|
237
|
+
this.def.reportAssets(`🛜 Send-assets-report-start`)
|
|
314
238
|
this.def.reportAssets(`🛜 ${response?.data?.report.join('\n🛜 ')}`)
|
|
315
|
-
this.def.reportAssets(`🛜 Send-
|
|
316
|
-
|
|
317
|
-
const plan = response?.data?.plan
|
|
318
|
-
if (!F3.obj.isGood(plan)) F3.throw(`missing-plan`)
|
|
319
|
-
|
|
320
|
-
await fsa.ensureFileDir(this.def.files.export.manifest)
|
|
321
|
-
await fsa.writeJSON(this.def.files.export.manifest, dataPlan.manifest)
|
|
322
|
-
this.def.reportAssets(`✅ written-manifest-sent \n💾 ${this.def.files.export.manifest}`)
|
|
323
|
-
|
|
324
|
-
await fsa.ensureFileDir(this.def.files.export.plan)
|
|
325
|
-
await fsa.writeJSON(this.def.files.export.plan, plan)
|
|
326
|
-
this.def.reportAssets(`✅ written-manifest-plan-response \n💾 ${this.def.files.export.plan}`)
|
|
327
|
-
|
|
328
|
-
if (!F3.obj.isGood(plan.upload)) {
|
|
329
|
-
this.def.writeAssets(target, '🔥🔥🔥 Sync.runAssets:success-already-in-sync')
|
|
330
|
-
return true
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
const uploadPaths = Object.keys(plan.upload)
|
|
334
|
-
const zip = new JSZip()
|
|
335
|
-
|
|
336
|
-
for (const relPath of uploadPaths) {
|
|
337
|
-
const fullPath = `${this.def.folders.volume}/${relPath}`
|
|
338
|
-
const buffer = await fsa.readFile(fullPath)
|
|
339
|
-
if (!buffer) F3.throw(`zip-missing-file:${relPath}`)
|
|
340
|
-
zip.file(relPath, buffer)
|
|
341
|
-
this.def.reportAssets(`✅ file-added-to-zip ${relPath}`)
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
await fsa.safeRemove(this.def.files.export.volumeZip)
|
|
345
|
-
this.def.reportAssets(`✅ removed-old-zip-folder`)
|
|
346
|
-
|
|
347
|
-
await fsa.ensureFileDir(this.def.files.export.volumeZip)
|
|
348
|
-
this.def.reportAssets(`✅ created-new-zip-folder`)
|
|
239
|
+
this.def.reportAssets(`🛜 Send-assets-report-end`)
|
|
349
240
|
|
|
350
|
-
|
|
351
|
-
await fsa.writeFile(this.def.files.export.volumeZip, bufferZip)
|
|
352
|
-
this.def.reportAssets(`✅ written-zip \n💾 ${this.def.files.export.volumeZip}`)
|
|
353
|
-
|
|
354
|
-
const initSender = {}
|
|
355
|
-
initSender.crypto = crypto
|
|
356
|
-
initSender.fileEndpoint = this.def.endpoints.file
|
|
357
|
-
initSender.chunkEndpoint = this.def.endpoints.chunk
|
|
358
|
-
initSender.statusEndpoint = this.def.endpoints.status
|
|
359
|
-
initSender.finalizeEndpoint = this.def.endpoints.finalize
|
|
360
|
-
const sender = new Sender(initSender)
|
|
361
|
-
|
|
362
|
-
const argsUpload = {}
|
|
363
|
-
argsUpload.bytes = bufferZip
|
|
364
|
-
argsUpload.target = this.def.app.target
|
|
365
|
-
argsUpload.token = await auth.getToken()
|
|
366
|
-
argsUpload.payload = {}
|
|
367
|
-
argsUpload.payload.callback = 'assets'
|
|
368
|
-
argsUpload.payload.importId = plan.importId
|
|
369
|
-
argsUpload.payload.clientId = this.def.app.clientId
|
|
370
|
-
|
|
371
|
-
this.def.reportAssets(`🛜 Send-assets-zip ${this.def.endpoints.plan}`)
|
|
372
|
-
|
|
373
|
-
const senderRes = await sender.upload(argsUpload)
|
|
374
|
-
|
|
375
|
-
this.def.reportAssets(`🛜 Send-assets-zip-report-start`)
|
|
376
|
-
this.def.reportAssets(`🛜 ${senderRes?.callback?.report.join('\n🛜 ')}`)
|
|
377
|
-
this.def.reportAssets(`🛜 Send-assets-zip-report-end`)
|
|
378
|
-
|
|
379
|
-
if (senderRes?.callback?.isOk) this.def.writeAssets(target, `🔥🔥🔥 Sync.runAssets:success`)
|
|
241
|
+
if (response?.data?.isOk) this.def.writeAssets(target, `🔥🔥🔥 Sync.runAssets:success`)
|
|
380
242
|
else this.def.writeAssets(target, `❌❌❌ Sync.runAssets:failed`)
|
|
381
243
|
|
|
382
244
|
} catch (e) {
|
|
@@ -402,10 +264,6 @@ export class Sync {
|
|
|
402
264
|
|
|
403
265
|
const response = await axios.post(this.def.endpoints.workers, payload)
|
|
404
266
|
|
|
405
|
-
this.def.reportWorkers(`🛜 Send-workers-report-start`)
|
|
406
|
-
this.def.reportWorkers(`🛜 ${response?.data?.report.join('\n🛜 ')}`)
|
|
407
|
-
this.def.reportWorkers(`🛜 Send-workers-report-end`)
|
|
408
|
-
|
|
409
267
|
if (response?.data?.isLocal) {
|
|
410
268
|
|
|
411
269
|
const local = {}
|
|
@@ -419,6 +277,10 @@ export class Sync {
|
|
|
419
277
|
return true
|
|
420
278
|
}
|
|
421
279
|
|
|
280
|
+
this.def.reportWorkers(`🛜 Send-workers-report-start`)
|
|
281
|
+
this.def.reportWorkers(`🛜 ${response?.data?.report.join('\n🛜 ')}`)
|
|
282
|
+
this.def.reportWorkers(`🛜 Send-workers-report-end`)
|
|
283
|
+
|
|
422
284
|
if (response?.data?.isOk) this.def.writeWorkers(target, `🔥🔥🔥 Sync.runWorkers:success`)
|
|
423
285
|
else this.def.writeWorkers(target, `❌❌❌ Sync.runWorkers:failed`)
|
|
424
286
|
|
|
@@ -427,4 +289,4 @@ export class Sync {
|
|
|
427
289
|
F3.catch.throw(e)
|
|
428
290
|
}
|
|
429
291
|
}
|
|
430
|
-
}
|
|
292
|
+
}
|
|
@@ -16,17 +16,17 @@ export class Tools {
|
|
|
16
16
|
return `${timestamp}-${days[d.getDay()]}.${String(d.getDate()).padStart(2, '0')}.${months[d.getMonth()]}.${d.getFullYear()}-${String(d.getHours()).padStart(2, '0')}.${String(d.getMinutes()).padStart(2, '0')}`
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
getManifest = async () => {
|
|
19
|
+
getManifest = async (basePath = this.def.folders.volume, schema = 'manifest.raw.sync.request', filter = null) => {
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
22
|
|
|
23
23
|
const manifest = {}
|
|
24
|
-
manifest.schema =
|
|
24
|
+
manifest.schema = schema
|
|
25
25
|
manifest.date = this.getManifestDate()
|
|
26
26
|
manifest.version = 1
|
|
27
27
|
manifest.total = 0
|
|
28
28
|
manifest.files = {}
|
|
29
|
-
await this.addFiles(
|
|
29
|
+
await this.addFiles(basePath, '', manifest, filter)
|
|
30
30
|
await fsa.ensureFileDir(this.def.files.export.manifest)
|
|
31
31
|
await fsa.writeJSON(this.def.files.export.manifest, manifest)
|
|
32
32
|
return manifest
|
|
@@ -34,8 +34,39 @@ export class Tools {
|
|
|
34
34
|
} catch (error) { F3.catch.throw(error, 'sync-client-getManifest-failed') }
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
getWorkspaceManifest = async () => {
|
|
38
|
+
return await this.getManifest(this.def.workspace, 'manifest.workspace.sync.request', relPath => this.isWorkspaceFile(relPath))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
isWorkspaceFile = (relPath = '') => {
|
|
42
|
+
|
|
43
|
+
if (!F3.str.isGood(relPath)) return false
|
|
44
|
+
|
|
45
|
+
const root = relPath.split('/')[0]
|
|
46
|
+
if (!['config', 'volume'].includes(root)) return false
|
|
47
|
+
|
|
48
|
+
const reports = [
|
|
49
|
+
'local.workspace.md',
|
|
50
|
+
'local.assets.md',
|
|
51
|
+
'local.workers.md',
|
|
52
|
+
'sv1.workspace.md',
|
|
53
|
+
'sv1.assets.md',
|
|
54
|
+
'sv1.workers.md',
|
|
55
|
+
'stage.workspace.md',
|
|
56
|
+
'stage.assets.md',
|
|
57
|
+
'stage.workers.md',
|
|
58
|
+
'production.workspace.md',
|
|
59
|
+
'production.assets.md',
|
|
60
|
+
'production.workers.md'
|
|
61
|
+
]
|
|
37
62
|
|
|
38
|
-
|
|
63
|
+
if (reports.includes(relPath)) return false
|
|
64
|
+
|
|
65
|
+
return true
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
addFiles = async (basePath, rel = '', manifest, filter = null) => {
|
|
39
70
|
|
|
40
71
|
const dir = rel ? `${basePath}/${rel}` : basePath
|
|
41
72
|
const entries = await fsa.readDir(dir)
|
|
@@ -49,10 +80,12 @@ export class Tools {
|
|
|
49
80
|
const stat = await fsa.stat(fullPath)
|
|
50
81
|
|
|
51
82
|
if (stat.isDirectory()) {
|
|
52
|
-
await this.addFiles(basePath, nextRel, manifest)
|
|
83
|
+
await this.addFiles(basePath, nextRel, manifest, filter)
|
|
53
84
|
continue
|
|
54
85
|
}
|
|
55
86
|
|
|
87
|
+
if (typeof filter === 'function' && !filter(nextRel)) continue
|
|
88
|
+
|
|
56
89
|
const buffer = await fsa.readFile(fullPath)
|
|
57
90
|
const hash = this.hash(buffer)
|
|
58
91
|
manifest.files[nextRel] = hash
|
|
@@ -99,4 +132,4 @@ export class Tools {
|
|
|
99
132
|
ref[last] = val
|
|
100
133
|
}
|
|
101
134
|
|
|
102
|
-
}
|
|
135
|
+
}
|