Skip to content

Commit 192557b

Browse files
authored
feat: add script to enable exporting and importing of sites (#1608)
* feat: add script to enable exporting and importing of sites * fix: adjust based on security findings * chore: fix package.json * chore: fix package.json
1 parent 0d1b281 commit 192557b

File tree

8 files changed

+1193
-180
lines changed

8 files changed

+1193
-180
lines changed

package-lock.json

Lines changed: 206 additions & 178 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/build/scripts/publishing/.env.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ DB_PORT=5432
66
DB_NAME=isomer_studio
77

88
SITE_ID=1
9-
AMPLIFY_APP_ID=123
109

1110
# optional to set, default is false
1211
# set to true to print more debug logs
13-
DEBUG=false
12+
DEBUG=false

tooling/export-import/.env.example

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
LOCAL_DB_USERNAME=local_user
2+
LOCAL_DB_PASSWORD=
3+
LOCAL_DB_HOST=localhost
4+
LOCAL_DB_PORT=5432
5+
LOCAL_DB_NAME=isomer_studio
6+
LOCAL_PUBLISHER_USER_ID=aaa
7+
8+
STAGING_AWS_PROFILE=isomer-staging
9+
STAGING_AWS_S3_ASSETS_BUCKET_NAME=
10+
STAGING_DB_USERNAME=local_user
11+
STAGING_DB_PASSWORD=
12+
STAGING_DB_HOST=localhost
13+
STAGING_DB_PORT=5432
14+
STAGING_DB_NAME=isomer_studio
15+
STAGING_PUBLISHER_USER_ID=aaa
16+
17+
UAT_AWS_PROFILE=isomer-uat
18+
UAT_AWS_S3_ASSETS_BUCKET_NAME=
19+
UAT_DB_USERNAME=local_user
20+
UAT_DB_PASSWORD=
21+
UAT_DB_HOST=localhost
22+
UAT_DB_PORT=5432
23+
UAT_DB_NAME=isomer_studio
24+
UAT_PUBLISHER_USER_ID=aaa
25+
26+
PROD_AWS_PROFILE=isomer-production
27+
PROD_AWS_S3_ASSETS_BUCKET_NAME=
28+
PROD_DB_USERNAME=local_user
29+
PROD_DB_PASSWORD=
30+
PROD_DB_HOST=localhost
31+
PROD_DB_PORT=5432
32+
PROD_DB_NAME=isomer_studio
33+
PROD_PUBLISHER_USER_ID=aaa

tooling/export-import/constants.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export const ENVIRONMENT_CHOICES = [
2+
{ name: "Local development", value: "LOCAL" },
3+
{ name: "Staging", value: "STAGING" },
4+
{ name: "UAT", value: "UAT" },
5+
{ name: "Production", value: "PROD" },
6+
];
7+
8+
export const GET_ALL_RESOURCES_WITH_FULL_PERMALINKS = `
9+
WITH RECURSIVE "resourcePath" (id, title, permalink, parentId, type, "fullPermalink", "blobId") AS (
10+
-- Base case for all resources
11+
SELECT
12+
r.id,
13+
r.title,
14+
r.permalink,
15+
r."parentId",
16+
r.type,
17+
r.permalink AS "fullPermalink",
18+
v."blobId"
19+
FROM
20+
public."Resource" r
21+
LEFT JOIN public."Version" v ON v."id" = r."publishedVersionId"
22+
WHERE r."siteId" = $1 AND r."parentId" IS NULL
23+
UNION ALL
24+
-- Recursive case
25+
SELECT
26+
r.id,
27+
r.title,
28+
r.permalink,
29+
r."parentId",
30+
r.type,
31+
CONCAT(path."fullPermalink", '/', r.permalink) AS "fullPermalink",
32+
v."blobId"
33+
FROM
34+
public."Resource" r
35+
LEFT JOIN public."Version" v ON v."id" = r."publishedVersionId"
36+
-- This join determines if the recursion continues if there are more rows
37+
INNER JOIN "resourcePath" path ON r."parentId" = path.id
38+
WHERE r."siteId" = $1
39+
)
40+
SELECT * FROM "resourcePath";
41+
`;

0 commit comments

Comments
 (0)