diff --git a/.github/workflows/lint-build.yml b/.github/workflows/lint-build.yml index 411f5de2..04c36524 100644 --- a/.github/workflows/lint-build.yml +++ b/.github/workflows/lint-build.yml @@ -4,6 +4,9 @@ on: pull_request: branches: - main +concurrency: + group: lint-build-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build: if: "!contains(github.event.pull_request.labels.*.name, 'Test - preview')" diff --git a/.github/workflows/preview-webhook.yml b/.github/workflows/preview-webhook.yml new file mode 100644 index 00000000..175c45f3 --- /dev/null +++ b/.github/workflows/preview-webhook.yml @@ -0,0 +1,14 @@ +# Generate static site preview for production site +name: Production Preview +on: + repository_dispatch: + types: [production_preview] +jobs: + run_if_failure: + if: ${{ !github.event.client_payload.passed }} + runs-on: ubuntu-latest + steps: + - env: + MESSAGE: ${{ github.event.client_payload.message }} + run: echo $MESSAGE +# TODO - trigger preview build diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 00000000..8cd45658 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,91 @@ +# Generate static site preview for production site +name: Production Preview +on: + workflow_call: + push: + branches: main +# Only keep one active build per ref (e.g. pr branch, push branch, triggering workflow ref) +concurrency: + group: preview-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + lfs: true + - name: Setup Node 18 + uses: actions/setup-node@v3 + with: + node-version: 18.x + + ############################################################################# + # Node Modules + # Manually restore any previous cache to speed install + # As immutable install will not change cache only save new cache if not hit + # Uses fine-grained methods from https://github.com/actions/cache + ############################################################################# + + - uses: actions/cache/restore@v3 + id: cache + with: + path: ./.yarn/cache + key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node-modules-yarn-v1- + - name: Install node modules + run: yarn install --immutable && npm i -g vercel + - uses: actions/cache/save@v3 + if: steps.cache.outputs.cache-hit != 'true' + with: + path: ./.yarn/cache + key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('yarn.lock') }} + + ############################################################################# + # Gcloud Setup + # Populate service account credentials to file + # Authenticate to google servers + # Initialize gcloud cli + ############################################################################# + - name: Setup Credentials + id: service-account + run: | + echo ${{secrets.GCP_SA_KEY_B64}} | base64 --decode > ./service-account.json + - name: GCP Auth + uses: "google-github-actions/auth@v2" + with: + project_id: "sami-website-365718" + credentials_json: ${{secrets.GCP_SA_KEY_B64}} + token_format: "access_token" + - name: "Set up Cloud SDK" + uses: "google-github-actions/setup-gcloud@v2" + with: + version: ">= 363.0.0" + + ############################################################################# + # Export production + ############################################################################# + # TODO - refactor actions - reusable build, export, deploy, hooks, pr generate etc. + + # Export production and rename to match dev configuration (production-local) + - name: Import production data locally + run: | + echo "STRAPI_READONLY_TOKEN=${{secrets.STRAPI_READONLY_TOKEN}}" > config/docker.local.env + yarn scripts strapi export --environment docker --ci + cp config/docker.local.env config/development.local.env + cp data/db/sami-production.db data/db/sami-dev.db + + - name: Build + run: yarn scripts cli build --environment=development --no-export --no-preview --no-deploy + # HACK - split build-deploy above for easier debugging + - name: Deploy + run: | + cd frontend + vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + vercel build --token=${{ secrets.VERCEL_TOKEN }} + vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} + + # NOTE - also possible to do without intermediate but requires interaction with live cloud-run api + # - name: Generate preview + # run: yarn scripts cli build --environment=docker --export --no-backend --no-preview --deploy diff --git a/.gitignore b/.gitignore index d9074d24..43734d35 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,4 @@ scripts/input scripts/output .vercel -service.yaml \ No newline at end of file +service*.yaml \ No newline at end of file diff --git a/_deprecated/ci/Pulumi.production.yaml b/_deprecated/ci/Pulumi.production.yaml index a8bb36cb..977e4731 100644 --- a/_deprecated/ci/Pulumi.production.yaml +++ b/_deprecated/ci/Pulumi.production.yaml @@ -1,4 +1,4 @@ config: gcp:project: sami-website-365718 - gcp:region: europe-west2 - sami-website:GCS_STORAGE_BUCKET: sami_website_uploads + gcp:region: europe-west1 + sami-website:GCS_STORAGE_BUCKET: sami_website_public diff --git a/_deprecated/ci/Pulumi.staging.yaml b/_deprecated/ci/Pulumi.staging.yaml index eec772dd..44f5ead9 100644 --- a/_deprecated/ci/Pulumi.staging.yaml +++ b/_deprecated/ci/Pulumi.staging.yaml @@ -1,4 +1,4 @@ config: gcp:project: sami-website-365718 - gcp:region: europe-west2 - sami-website:GCS_STORAGE_BUCKET: sami_website_uploads_staging + gcp:region: europe-west1 + sami-website:GCS_STORAGE_BUCKET: sami_website_public_staging diff --git a/_deprecated/ci/services/docker-strapi-image-build.ts b/_deprecated/ci/services/docker-strapi-image-build.ts index 75aa3072..269d73ef 100644 --- a/_deprecated/ci/services/docker-strapi-image-build.ts +++ b/_deprecated/ci/services/docker-strapi-image-build.ts @@ -8,13 +8,13 @@ import { PATHS } from "../utils"; * Prerequisites * ``` * gcloud auth ... application-default (TO CONFIRM FROM GUIDE) - * gcloud auth configure-docker europe-west2-docker.pkg.dev + * gcloud auth configure-docker europe-west1-docker.pkg.dev * ``` * * https://github.com/pulumi/pulumi-docker/blob/master/examples/container-registries/gcp/ts/index.ts */ export function DockerStrapiImageBuild(envName: string) { - const location = gcp.config.region || "europe-west2"; + const location = gcp.config.region || "europe-west1"; const repositoryId = `sami-website-${envName}`; const project = gcp.config.project; diff --git a/_deprecated/ci/services/gcp-cloudrun-deploy.ts b/_deprecated/ci/services/gcp-cloudrun-deploy.ts index 60bee7a1..6e14e1e1 100644 --- a/_deprecated/ci/services/gcp-cloudrun-deploy.ts +++ b/_deprecated/ci/services/gcp-cloudrun-deploy.ts @@ -15,7 +15,7 @@ export function GCPCloudRunDeploy(image: docker.Image, envName: string, envVars: }); // Location to deploy Cloud Run services - const location = gcp.config.region || "europe-west2"; + const location = gcp.config.region || "europe-west1"; const fullImageName = image.imageName; // Environment variables diff --git a/_deprecated/ci/utils/gcp-storage-create.ts b/_deprecated/ci/utils/gcp-storage-create.ts index 29b91039..c573b6d8 100644 --- a/_deprecated/ci/utils/gcp-storage-create.ts +++ b/_deprecated/ci/utils/gcp-storage-create.ts @@ -9,7 +9,7 @@ import * as gcp from "@pulumi/gcp"; */ export function GCPCStorageCreate(bucketname: string) { - const location = gcp.config.region || "europe-west2"; + const location = gcp.config.region || "europe-west1"; // Create a GCP resource (Storage Bucket) const bucket = new gcp.storage.Bucket(bucketname, { location, diff --git a/_deprecated/config/docker-compose.env b/_deprecated/config/docker-compose.env new file mode 100644 index 00000000..0135df01 --- /dev/null +++ b/_deprecated/config/docker-compose.env @@ -0,0 +1,5 @@ +# Additional env required when running via docker-compose + +# Domain pointed at server to generate https certs +PUBLIC_DOMAIN=next.sami.local +LETS_ENCRYPT_EMAIL=email@domain.com \ No newline at end of file diff --git a/_deprecated/config/staging.env b/_deprecated/config/staging.env index f6894bc0..23f1b105 100644 --- a/_deprecated/config/staging.env +++ b/_deprecated/config/staging.env @@ -19,7 +19,7 @@ DATABASE_URL=postgres://wspestjk:gLtUYEmdq4WWsglVo3OTbGtg7P0wtS0m@surus.db.eleph # If using a service worker will require access to bucket GOOGLE_APPLICATION_CREDENTIALS=./service-account.json -GCS_BUCKET_NAME=sami_website_uploads_staging-bf0d161 +GCS_BUCKET_NAME=sami_website_public_staging-bf0d161 GCS_PUBLIC_FILES=true GCS_UNIFORM=false diff --git a/config/docker.env b/config/docker.env index 0f672394..31556840 100644 --- a/config/docker.env +++ b/config/docker.env @@ -1,6 +1,4 @@ -# Domain pointed at server to generate https certs -PUBLIC_DOMAIN=next.sami.local -LETS_ENCRYPT_EMAIL=email@domain.com + # Strapi Configuration # NOTE - changes to these will require new strapi build (?) @@ -22,13 +20,13 @@ DATABASE_FILENAME=sami-production.db # Or exporting locally GCP_PROJECT=sami-website-365718 GCS_DB_BUCKET_NAME=sami_website_db -GCS_PUBLIC_BUCKET_NAME=sami_website_uploads +GCS_PUBLIC_BUCKET_NAME=sami_website_public # Paseed from compose # STRAPI_READONLY_TOKEN=TO_BE_GENERATED # Connect to API directly but serve image from public url -NEXT_PUBLIC_API_URL=http://backend:1337 +NEXT_PUBLIC_API_URL=https://admin.samicharity.co.uk # Images uploaded in backed are shared directly with frontend via volumes # So just load from self diff --git a/cspell.json b/cspell.json index 57795c27..13d9dc44 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,7 @@ "ignorePaths": ["**/*.ts", "**/*.js", "**/dist"], "dictionaryDefinitions": [], "dictionaries": [], - "words": ["strapi", "sami", "ami"], + "words": ["strapi", "sami", "ami", "vercel"], "ignoreWords": [], "import": [] } diff --git a/data/db-json/components_common_htmls.json b/data/db-json/components_common_htmls.json index 5110b604..a02d8105 100644 --- a/data/db-json/components_common_htmls.json +++ b/data/db-json/components_common_htmls.json @@ -112,11 +112,11 @@ "id": 29 }, { - "html": "

Background

The African Data Initiative (ADI) is an on-going effort to help design and build statistical software that can easily be used throughout the developing world. It started through a crowd-funding campaign in November 2015, where close to £33,000 was raised to fund the initial development.

Current Progress

The team in Kenya has been incredibly busy working on the software, and had their first beta release in November 2016, one year on from the project start. Since then it has been showcased at numerous workshops and conferences, and received additional funding to support specific development to help explore climatic modelling and combat corruption.

 

\"Danny

Danny presents the software at a conference in Kenya

 

\"The

The ADI team working together in Tanzania

 

Future Plans

R-Instat is looking towards its official release in July 2017 at the World Statistics Congress in Morocco.

", + "html": "

Background

The African Data Initiative (ADI) is an on-going effort to help design and build statistical software that can easily be used throughout the developing world. It started through a crowd-funding campaign in November 2015, where close to £33,000 was raised to fund the initial development.

Current Progress

The team in Kenya has been incredibly busy working on the software, and had their first beta release in November 2016, one year on from the project start. Since then it has been showcased at numerous workshops and conferences, and received additional funding to support specific development to help explore climatic modelling and combat corruption.

", "id": 30 }, { - "html": "

Background

\"The

The Digital Communities Initiative uses technology to support across diverse areas including schools, agriculture and women in enterprise.

 

In 2016 SAMI applied for a small grant from the Economist Charitable Trust to pilot a new project aimed at using technology to improve livelihoods across a community.

We initially started with a set of 20 android tablets that were taken out to the Kitale region of Western Kenya. We’ve been hard at work to find innovative and effective ways that the technology can be used to support people, with an initial focus on schools, agriculture and enterprising women.

Since then the project has expanded to include more than 60 devices, and we are working with organisations and institutions around the world to provide real impact, with costs involved kept to a minimum. You can see the first update report published by the DCI team below:

Updates May 2017

 

Page 1 / 26

 

Zoom 100%

 

Future Plans

We have been incredibly excited to see the huge impact seen through DCI, and are currently looking for ways to extend the project through 2017-2018.

", + "html": "

Background

", "id": 31 }, { @@ -142,5 +142,13 @@ { "html": "

For each camp we aim to have at least one experienced volunteer. Further, we aim to have at least one international teacher at each camp, either a current teacher or a retired teacher. We aim to also have two to three student international volunteers participate in each of the AMI camps, with the volunteers being a mixture of undergrads and postgrads/researchers. We would be happy to hear from people in other walks of life who feel they have something to contribute, and we would consider recommending high school students for this experience.

The recruitment of international volunteers has begun and we will be considering applications on a rolling basis until the start of the camps. You can mention a preference for a camp in your application, but you don’t have to. Decisions on applications will be made by the SAMI Trustees, who then recommend suitable candidates to the local organisers of the respective camps. Note: all camps are run through local partners. As such, dates and venues are subject to change. 

Do not make any flight or accommodation booking until you have confirmed the camp dates with the local organiser

SAMI cannot accept responsibility for any financial loss occurred due to the changes in dates or venues for any of the camps.

FAQs can be found below. If you would like to know more please write to admin@supportingami.org. We’re happy to give you more information by email and would be happy to meet you in person.

", "id": 37 + }, + { + "html": "

Future Plans

R-Instat is looking towards its official release in July 2017 at the World Statistics Congress in Morocco.

", + "id": 38 + }, + { + "html": "

The Digital Communities Initiative uses technology to support across diverse areas including schools, agriculture and women in enterprise.

In 2016 SAMI applied for a small grant from the Economist Charitable Trust to pilot a new project aimed at using technology to improve livelihoods across a community.

We initially started with a set of 20 android tablets that were taken out to the Kitale region of Western Kenya. We’ve been hard at work to find innovative and effective ways that the technology can be used to support people, with an initial focus on schools, agriculture and enterprising women.

Since then the project has expanded to include more than 60 devices, and we are working with organisations and institutions around the world to provide real impact, with costs involved kept to a minimum. You can see the first update report published by the DCI team below:

Updates May 2017

 

 

Future Plans

We have been incredibly excited to see the huge impact seen through DCI, and are currently looking for ways to extend the project through 2017-2018.

", + "id": 39 } ] diff --git a/data/db-json/components_common_images.json b/data/db-json/components_common_images.json index ed3b6f22..9d840e34 100644 --- a/data/db-json/components_common_images.json +++ b/data/db-json/components_common_images.json @@ -70,5 +70,23 @@ "caption": "\n", "class_names": "max-w-lg", "id": 12 + }, + { + "alt_text": null, + "caption": "Danny presents the software at a conference in Kenya", + "class_names": null, + "id": 13 + }, + { + "alt_text": null, + "caption": "The ADI team working together in Tanzania", + "class_names": null, + "id": 14 + }, + { + "alt_text": null, + "caption": "The Digital Communities Initiative uses technology to support across diverse areas including schools, agriculture and women in enterprise.", + "class_names": "max-w-md mx-auto", + "id": 15 } ] diff --git a/data/db-json/files.json b/data/db-json/files.json index bd50a90c..73b9934e 100644 --- a/data/db-json/files.json +++ b/data/db-json/files.json @@ -1578,7 +1578,7 @@ "provider": "local", "provider_metadata": null, "size": 136.07, - "updated_at": 1699899304689, + "updated_at": 1711170925539, "updated_by_id": 1, "url": "/uploads/sami_maths_club_2f3a69af37.jpg", "width": 900 @@ -2022,5 +2022,49 @@ "updated_by_id": 1, "url": "/uploads/cabrine_4e57fc058c.png", "width": 129 + }, + { + "alternative_text": null, + "caption": null, + "created_at": 1711170050526, + "created_by_id": 1, + "ext": ".webp", + "folder_path": "/7/14", + "formats": "{\"thumbnail\":{\"name\":\"thumbnail_ADI-dev-tanzania.webp\",\"hash\":\"thumbnail_ADI_dev_tanzania_5b4f7c165e\",\"ext\":\".webp\",\"mime\":\"image/webp\",\"path\":null,\"width\":245,\"height\":138,\"size\":7.45,\"url\":\"/uploads/thumbnail_ADI_dev_tanzania_5b4f7c165e.webp\"}}", + "hash": "ADI_dev_tanzania_5b4f7c165e", + "height": 531, + "id": 126, + "mime": "image/webp", + "name": "ADI-dev-tanzania.webp", + "preview_url": null, + "provider": "local", + "provider_metadata": null, + "size": 470.64, + "updated_at": 1711170050526, + "updated_by_id": 1, + "url": "/uploads/ADI_dev_tanzania_5b4f7c165e.webp", + "width": 944 + }, + { + "alternative_text": null, + "caption": null, + "created_at": 1711246276379, + "created_by_id": 1, + "ext": ".webp", + "folder_path": "/7/15", + "formats": "{\"thumbnail\":{\"name\":\"thumbnail_DCI.webp\",\"hash\":\"thumbnail_DCI_c29bc1b654\",\"ext\":\".webp\",\"mime\":\"image/webp\",\"path\":null,\"width\":216,\"height\":156,\"size\":8.96,\"url\":\"/uploads/thumbnail_DCI_c29bc1b654.webp\"}}", + "hash": "DCI_c29bc1b654", + "height": 632, + "id": 127, + "mime": "image/webp", + "name": "DCI.webp", + "preview_url": null, + "provider": "local", + "provider_metadata": null, + "size": 101.75, + "updated_at": 1711246276379, + "updated_by_id": 1, + "url": "/uploads/DCI_c29bc1b654.webp", + "width": 874 } ] diff --git a/data/db-json/files_folder_links.json b/data/db-json/files_folder_links.json index 8b91f2fc..bc163ede 100644 --- a/data/db-json/files_folder_links.json +++ b/data/db-json/files_folder_links.json @@ -544,5 +544,17 @@ "file_order": 2, "folder_id": 14, "id": 103 + }, + { + "file_id": 126, + "file_order": 1, + "folder_id": 15, + "id": 104 + }, + { + "file_id": 127, + "file_order": 1, + "folder_id": 16, + "id": 106 } ] diff --git a/data/db-json/files_related_morphs.json b/data/db-json/files_related_morphs.json index d9885e75..df09b542 100644 --- a/data/db-json/files_related_morphs.json +++ b/data/db-json/files_related_morphs.json @@ -338,7 +338,7 @@ { "field": "Icon", "file_id": 70, - "id": 173, + "id": 334, "order": 1, "related_id": 4, "related_type": "api::project-type.project-type" @@ -354,7 +354,7 @@ { "field": "Icon", "file_id": 72, - "id": 171, + "id": 312, "order": 1, "related_id": 3, "related_type": "api::project-type.project-type" @@ -378,7 +378,7 @@ { "field": "FeatureImage", "file_id": 75, - "id": 174, + "id": 335, "order": 1, "related_id": 4, "related_type": "api::project-type.project-type" @@ -394,11 +394,19 @@ { "field": "FeatureImage", "file_id": 77, - "id": 172, + "id": 313, "order": 1, "related_id": 3, "related_type": "api::project-type.project-type" }, + { + "field": "Media", + "file_id": 77, + "id": 310, + "order": 1, + "related_id": 13, + "related_type": "common.image" + }, { "field": "FeatureImage", "file_id": 78, @@ -814,5 +822,21 @@ "order": 1, "related_id": 1, "related_type": "api::testimonial.testimonial" + }, + { + "field": "Media", + "file_id": 126, + "id": 311, + "order": 1, + "related_id": 14, + "related_type": "common.image" + }, + { + "field": "Media", + "file_id": 127, + "id": 333, + "order": 1, + "related_id": 15, + "related_type": "common.image" } ] diff --git a/data/db-json/project_types.json b/data/db-json/project_types.json index 137120e2..48114ca6 100644 --- a/data/db-json/project_types.json +++ b/data/db-json/project_types.json @@ -35,7 +35,7 @@ "published_at": 1661672067691, "slug": "african-data", "status": "Ongoing", - "updated_at": 1699914141550, + "updated_at": 1711170056676, "updated_by_id": 1 }, { @@ -48,7 +48,7 @@ "published_at": 1661671848434, "slug": "digital-communities", "status": "Completed", - "updated_at": 1699915756731, + "updated_at": 1711247205987, "updated_by_id": 1 }, { diff --git a/data/db-json/project_types_components.json b/data/db-json/project_types_components.json index 584790ca..88c666cb 100644 --- a/data/db-json/project_types_components.json +++ b/data/db-json/project_types_components.json @@ -1,20 +1,4 @@ [ - { - "component_id": 30, - "component_type": "common.html", - "entity_id": 3, - "field": "PageContent", - "id": 13, - "order": 1 - }, - { - "component_id": 31, - "component_type": "common.html", - "entity_id": 4, - "field": "PageContent", - "id": 14, - "order": 1 - }, { "component_id": 32, "component_type": "common.html", @@ -86,5 +70,61 @@ "field": "PageContent", "id": 40, "order": 7 + }, + { + "component_id": 30, + "component_type": "common.html", + "entity_id": 3, + "field": "PageContent", + "id": 41, + "order": 1 + }, + { + "component_id": 13, + "component_type": "common.image", + "entity_id": 3, + "field": "PageContent", + "id": 42, + "order": 2 + }, + { + "component_id": 14, + "component_type": "common.image", + "entity_id": 3, + "field": "PageContent", + "id": 43, + "order": 3 + }, + { + "component_id": 38, + "component_type": "common.html", + "entity_id": 3, + "field": "PageContent", + "id": 44, + "order": 4 + }, + { + "component_id": 31, + "component_type": "common.html", + "entity_id": 4, + "field": "PageContent", + "id": 60, + "order": 1 + }, + { + "component_id": 15, + "component_type": "common.image", + "entity_id": 4, + "field": "PageContent", + "id": 61, + "order": 2 + }, + { + "component_id": 39, + "component_type": "common.html", + "entity_id": 4, + "field": "PageContent", + "id": 62, + "order": 3 } ] diff --git a/data/db-json/sqlite_sequence.json b/data/db-json/sqlite_sequence.json index 9b0dd3d9..b529bd56 100644 --- a/data/db-json/sqlite_sequence.json +++ b/data/db-json/sqlite_sequence.json @@ -25,11 +25,11 @@ }, { "name": "components_common_htmls", - "seq": 37 + "seq": 39 }, { "name": "components_common_images", - "seq": 12 + "seq": 15 }, { "name": "components_common_text_blocks", @@ -105,15 +105,15 @@ }, { "name": "files", - "seq": 125 + "seq": 127 }, { "name": "files_folder_links", - "seq": 103 + "seq": 106 }, { "name": "files_related_morphs", - "seq": 309 + "seq": 335 }, { "name": "home_contents", @@ -137,11 +137,11 @@ }, { "name": "project_types_components", - "seq": 40 + "seq": 62 }, { "name": "resources", - "seq": 5 + "seq": 6 }, { "name": "resources_components", @@ -153,11 +153,11 @@ }, { "name": "upload_folders", - "seq": 14 + "seq": 16 }, { "name": "upload_folders_parent_links", - "seq": 1 + "seq": 3 }, { "name": "volunteer_contents", diff --git a/data/db-json/upload_folders.json b/data/db-json/upload_folders.json index 1de05216..04f99f5d 100644 --- a/data/db-json/upload_folders.json +++ b/data/db-json/upload_folders.json @@ -128,5 +128,25 @@ "path_id": 13, "updated_at": 1710787443316, "updated_by_id": 1 + }, + { + "created_at": 1711170038972, + "created_by_id": 1, + "id": 15, + "name": "African Data", + "path": "/7/14", + "path_id": 14, + "updated_at": 1711170038972, + "updated_by_id": 1 + }, + { + "created_at": 1711246253618, + "created_by_id": 1, + "id": 16, + "name": "Digital Communities", + "path": "/7/15", + "path_id": 15, + "updated_at": 1711246253618, + "updated_by_id": 1 } ] diff --git a/data/db-json/upload_folders_parent_links.json b/data/db-json/upload_folders_parent_links.json index e8ddb0ca..537aefe2 100644 --- a/data/db-json/upload_folders_parent_links.json +++ b/data/db-json/upload_folders_parent_links.json @@ -4,5 +4,17 @@ "folder_order": 1, "id": 1, "inv_folder_id": 6 + }, + { + "folder_id": 15, + "folder_order": 1, + "id": 2, + "inv_folder_id": 8 + }, + { + "folder_id": 16, + "folder_order": 2, + "id": 3, + "inv_folder_id": 8 } ] diff --git a/data/public/images/bg-tiling-1.svg b/data/public/images/bg-tiling-1.svg new file mode 100644 index 00000000..8ca98ee6 --- /dev/null +++ b/data/public/images/bg-tiling-1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/data/public/images/bg-tiling-2.svg b/data/public/images/bg-tiling-2.svg new file mode 100644 index 00000000..b5d432cc --- /dev/null +++ b/data/public/images/bg-tiling-2.svg @@ -0,0 +1,72 @@ + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/data/public/images/favicon.ico b/data/public/images/favicon.ico new file mode 100644 index 00000000..fa2b0cdf Binary files /dev/null and b/data/public/images/favicon.ico differ diff --git a/data/public/images/sami-logo-no-text.svg b/data/public/images/sami-logo-no-text.svg new file mode 100644 index 00000000..9fe25aac --- /dev/null +++ b/data/public/images/sami-logo-no-text.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/data/public/images/sami-logo.svg b/data/public/images/sami-logo.svg new file mode 100644 index 00000000..0b08d384 --- /dev/null +++ b/data/public/images/sami-logo.svg @@ -0,0 +1 @@ +Supporting African Maths Initiatives \ No newline at end of file diff --git a/data/public/uploads/ADI_dev_tanzania_5b4f7c165e.webp b/data/public/uploads/ADI_dev_tanzania_5b4f7c165e.webp new file mode 100644 index 00000000..20f40326 Binary files /dev/null and b/data/public/uploads/ADI_dev_tanzania_5b4f7c165e.webp differ diff --git a/data/public/uploads/DCI_c29bc1b654.webp b/data/public/uploads/DCI_c29bc1b654.webp new file mode 100644 index 00000000..2e5fd508 Binary files /dev/null and b/data/public/uploads/DCI_c29bc1b654.webp differ diff --git a/data/public/uploads/large_2019_07_2000px_Flag_of_Cameroon_svg_932182d391.png b/data/public/uploads/large_2019_07_2000px_Flag_of_Cameroon_svg_932182d391.png deleted file mode 100644 index 2832f215..00000000 Binary files a/data/public/uploads/large_2019_07_2000px_Flag_of_Cameroon_svg_932182d391.png and /dev/null differ diff --git a/data/public/uploads/large_2020_01_IMG_20200109_WA_0052_8c1ad90ad8.jpg b/data/public/uploads/large_2020_01_IMG_20200109_WA_0052_8c1ad90ad8.jpg deleted file mode 100644 index e2367e72..00000000 Binary files a/data/public/uploads/large_2020_01_IMG_20200109_WA_0052_8c1ad90ad8.jpg and /dev/null differ diff --git a/data/public/uploads/large_2020_01_d89d37ac_c78d_4355_aae0_b9074a34fad2_c8e3b0abd7.jpg b/data/public/uploads/large_2020_01_d89d37ac_c78d_4355_aae0_b9074a34fad2_c8e3b0abd7.jpg deleted file mode 100644 index 34fc438c..00000000 Binary files a/data/public/uploads/large_2020_01_d89d37ac_c78d_4355_aae0_b9074a34fad2_c8e3b0abd7.jpg and /dev/null differ diff --git a/data/public/uploads/large_2020_05_21st_century_skills_6104c2836c.jpg b/data/public/uploads/large_2020_05_21st_century_skills_6104c2836c.jpg deleted file mode 100644 index 21a7f3e2..00000000 Binary files a/data/public/uploads/large_2020_05_21st_century_skills_6104c2836c.jpg and /dev/null differ diff --git a/data/public/uploads/large_Chris_Clarke_31b81e4e94.jpg b/data/public/uploads/large_Chris_Clarke_31b81e4e94.jpg deleted file mode 100644 index 3e3eabaf..00000000 Binary files a/data/public/uploads/large_Chris_Clarke_31b81e4e94.jpg and /dev/null differ diff --git a/data/public/uploads/large_maths_camp_1_d2efa44ea6.png b/data/public/uploads/large_maths_camp_1_d2efa44ea6.png deleted file mode 100644 index 4b683606..00000000 Binary files a/data/public/uploads/large_maths_camp_1_d2efa44ea6.png and /dev/null differ diff --git a/data/public/uploads/large_maths_camp_2_1c95862d07.png b/data/public/uploads/large_maths_camp_2_1c95862d07.png deleted file mode 100644 index ab14f20e..00000000 Binary files a/data/public/uploads/large_maths_camp_2_1c95862d07.png and /dev/null differ diff --git a/data/public/uploads/medium_2016_07_dci_front_fb97829509.png b/data/public/uploads/medium_2016_07_dci_front_fb97829509.png deleted file mode 100644 index acdf1ac1..00000000 Binary files a/data/public/uploads/medium_2016_07_dci_front_fb97829509.png and /dev/null differ diff --git a/data/public/uploads/medium_2019_07_2000px_Flag_of_Cameroon_svg_932182d391.png b/data/public/uploads/medium_2019_07_2000px_Flag_of_Cameroon_svg_932182d391.png deleted file mode 100644 index 79d653e4..00000000 Binary files a/data/public/uploads/medium_2019_07_2000px_Flag_of_Cameroon_svg_932182d391.png and /dev/null differ diff --git a/data/public/uploads/medium_2019_07_onebillion_Large_c3e245556c.png b/data/public/uploads/medium_2019_07_onebillion_Large_c3e245556c.png deleted file mode 100644 index 9f766f24..00000000 Binary files a/data/public/uploads/medium_2019_07_onebillion_Large_c3e245556c.png and /dev/null differ diff --git a/data/public/uploads/medium_2020_01_IMG_20200109_WA_0052_8c1ad90ad8.jpg b/data/public/uploads/medium_2020_01_IMG_20200109_WA_0052_8c1ad90ad8.jpg deleted file mode 100644 index 74fb5a13..00000000 Binary files a/data/public/uploads/medium_2020_01_IMG_20200109_WA_0052_8c1ad90ad8.jpg and /dev/null differ diff --git a/data/public/uploads/medium_2020_01_d89d37ac_c78d_4355_aae0_b9074a34fad2_c8e3b0abd7.jpg b/data/public/uploads/medium_2020_01_d89d37ac_c78d_4355_aae0_b9074a34fad2_c8e3b0abd7.jpg deleted file mode 100644 index 573731b6..00000000 Binary files a/data/public/uploads/medium_2020_01_d89d37ac_c78d_4355_aae0_b9074a34fad2_c8e3b0abd7.jpg and /dev/null differ diff --git a/data/public/uploads/medium_2020_05_21st_century_skills_6104c2836c.jpg b/data/public/uploads/medium_2020_05_21st_century_skills_6104c2836c.jpg deleted file mode 100644 index 43c86130..00000000 Binary files a/data/public/uploads/medium_2020_05_21st_century_skills_6104c2836c.jpg and /dev/null differ diff --git a/data/public/uploads/medium_2020_05_remote_learning_f6836c17ea.jpg b/data/public/uploads/medium_2020_05_remote_learning_f6836c17ea.jpg deleted file mode 100644 index 9a154f8f..00000000 Binary files a/data/public/uploads/medium_2020_05_remote_learning_f6836c17ea.jpg and /dev/null differ diff --git a/data/public/uploads/medium_2020_12_133753916_2833991540220117_586528112291405133_o_1_2edd8b164b.png b/data/public/uploads/medium_2020_12_133753916_2833991540220117_586528112291405133_o_1_2edd8b164b.png deleted file mode 100644 index 1c8d6376..00000000 Binary files a/data/public/uploads/medium_2020_12_133753916_2833991540220117_586528112291405133_o_1_2edd8b164b.png and /dev/null differ diff --git a/data/public/uploads/medium_2020_12_maths_club_app_3_20bb1dfa21.jpeg b/data/public/uploads/medium_2020_12_maths_club_app_3_20bb1dfa21.jpeg deleted file mode 100644 index ebd19e58..00000000 Binary files a/data/public/uploads/medium_2020_12_maths_club_app_3_20bb1dfa21.jpeg and /dev/null differ diff --git a/data/public/uploads/medium_Chris_Clarke_31b81e4e94.jpg b/data/public/uploads/medium_Chris_Clarke_31b81e4e94.jpg deleted file mode 100644 index f841c6a1..00000000 Binary files a/data/public/uploads/medium_Chris_Clarke_31b81e4e94.jpg and /dev/null differ diff --git a/data/public/uploads/medium_maths_camp_1_d2efa44ea6.png b/data/public/uploads/medium_maths_camp_1_d2efa44ea6.png deleted file mode 100644 index 799b6783..00000000 Binary files a/data/public/uploads/medium_maths_camp_1_d2efa44ea6.png and /dev/null differ diff --git a/data/public/uploads/medium_maths_camp_2_1c95862d07.png b/data/public/uploads/medium_maths_camp_2_1c95862d07.png deleted file mode 100644 index 748cad7e..00000000 Binary files a/data/public/uploads/medium_maths_camp_2_1c95862d07.png and /dev/null differ diff --git a/data/public/uploads/small_2016_07_dci_front_fb97829509.png b/data/public/uploads/small_2016_07_dci_front_fb97829509.png deleted file mode 100644 index 070306a8..00000000 Binary files a/data/public/uploads/small_2016_07_dci_front_fb97829509.png and /dev/null differ diff --git a/data/public/uploads/small_2019_07_2000px_Flag_of_Cameroon_svg_932182d391.png b/data/public/uploads/small_2019_07_2000px_Flag_of_Cameroon_svg_932182d391.png deleted file mode 100644 index e3f38830..00000000 Binary files a/data/public/uploads/small_2019_07_2000px_Flag_of_Cameroon_svg_932182d391.png and /dev/null differ diff --git a/data/public/uploads/small_2019_07_onebillion_Large_c3e245556c.png b/data/public/uploads/small_2019_07_onebillion_Large_c3e245556c.png deleted file mode 100644 index ba13db73..00000000 Binary files a/data/public/uploads/small_2019_07_onebillion_Large_c3e245556c.png and /dev/null differ diff --git a/data/public/uploads/small_2020_01_IMG_20200109_WA_0052_8c1ad90ad8.jpg b/data/public/uploads/small_2020_01_IMG_20200109_WA_0052_8c1ad90ad8.jpg deleted file mode 100644 index 98181220..00000000 Binary files a/data/public/uploads/small_2020_01_IMG_20200109_WA_0052_8c1ad90ad8.jpg and /dev/null differ diff --git a/data/public/uploads/small_2020_01_d89d37ac_c78d_4355_aae0_b9074a34fad2_c8e3b0abd7.jpg b/data/public/uploads/small_2020_01_d89d37ac_c78d_4355_aae0_b9074a34fad2_c8e3b0abd7.jpg deleted file mode 100644 index eea39145..00000000 Binary files a/data/public/uploads/small_2020_01_d89d37ac_c78d_4355_aae0_b9074a34fad2_c8e3b0abd7.jpg and /dev/null differ diff --git a/data/public/uploads/small_2020_03_iconfinder_wuhan_coronavirus_virus_outbreak_02_5730675_1b67ba8577.png b/data/public/uploads/small_2020_03_iconfinder_wuhan_coronavirus_virus_outbreak_02_5730675_1b67ba8577.png deleted file mode 100644 index 9cbea87c..00000000 Binary files a/data/public/uploads/small_2020_03_iconfinder_wuhan_coronavirus_virus_outbreak_02_5730675_1b67ba8577.png and /dev/null differ diff --git a/data/public/uploads/small_2020_05_21st_century_skills_6104c2836c.jpg b/data/public/uploads/small_2020_05_21st_century_skills_6104c2836c.jpg deleted file mode 100644 index 85be3da7..00000000 Binary files a/data/public/uploads/small_2020_05_21st_century_skills_6104c2836c.jpg and /dev/null differ diff --git a/data/public/uploads/small_2020_05_remote_learning_f6836c17ea.jpg b/data/public/uploads/small_2020_05_remote_learning_f6836c17ea.jpg deleted file mode 100644 index 3ca10697..00000000 Binary files a/data/public/uploads/small_2020_05_remote_learning_f6836c17ea.jpg and /dev/null differ diff --git a/data/public/uploads/small_2020_12_133753916_2833991540220117_586528112291405133_o_1_2edd8b164b.png b/data/public/uploads/small_2020_12_133753916_2833991540220117_586528112291405133_o_1_2edd8b164b.png deleted file mode 100644 index c48dd4d0..00000000 Binary files a/data/public/uploads/small_2020_12_133753916_2833991540220117_586528112291405133_o_1_2edd8b164b.png and /dev/null differ diff --git a/data/public/uploads/small_2020_12_maths_club_app_3_20bb1dfa21.jpeg b/data/public/uploads/small_2020_12_maths_club_app_3_20bb1dfa21.jpeg deleted file mode 100644 index 001f5f7f..00000000 Binary files a/data/public/uploads/small_2020_12_maths_club_app_3_20bb1dfa21.jpeg and /dev/null differ diff --git a/data/public/uploads/small_Chris_Clarke_31b81e4e94.jpg b/data/public/uploads/small_Chris_Clarke_31b81e4e94.jpg deleted file mode 100644 index 240b52e7..00000000 Binary files a/data/public/uploads/small_Chris_Clarke_31b81e4e94.jpg and /dev/null differ diff --git a/data/public/uploads/small_maths_camp_1_d2efa44ea6.png b/data/public/uploads/small_maths_camp_1_d2efa44ea6.png deleted file mode 100644 index 8d5b04ed..00000000 Binary files a/data/public/uploads/small_maths_camp_1_d2efa44ea6.png and /dev/null differ diff --git a/data/public/uploads/small_maths_camp_2_1c95862d07.png b/data/public/uploads/small_maths_camp_2_1c95862d07.png deleted file mode 100644 index fd21c565..00000000 Binary files a/data/public/uploads/small_maths_camp_2_1c95862d07.png and /dev/null differ diff --git a/data/public/uploads/small_placeholder_6155fc454c.png b/data/public/uploads/small_placeholder_6155fc454c.png deleted file mode 100644 index ef8de12c..00000000 Binary files a/data/public/uploads/small_placeholder_6155fc454c.png and /dev/null differ diff --git a/data/public/uploads/thumbnail_ADI_dev_tanzania_5b4f7c165e.webp b/data/public/uploads/thumbnail_ADI_dev_tanzania_5b4f7c165e.webp new file mode 100644 index 00000000..7b6b13ac Binary files /dev/null and b/data/public/uploads/thumbnail_ADI_dev_tanzania_5b4f7c165e.webp differ diff --git a/data/public/uploads/thumbnail_DCI_c29bc1b654.webp b/data/public/uploads/thumbnail_DCI_c29bc1b654.webp new file mode 100644 index 00000000..7b4ee6b0 Binary files /dev/null and b/data/public/uploads/thumbnail_DCI_c29bc1b654.webp differ diff --git a/docs/deployment.md b/docs/deployment.md index cbe21793..0612082b 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -56,6 +56,10 @@ volumes: bucketName: sami_website_public ``` +```yaml +run.googleapis.com/launch-stage: BETA +``` + Deploy via ```sh diff --git a/frontend/components/common/dynamic.tsx b/frontend/components/common/dynamic.tsx index 8e664b6b..6cc0bce0 100644 --- a/frontend/components/common/dynamic.tsx +++ b/frontend/components/common/dynamic.tsx @@ -18,6 +18,11 @@ import { getStrapiMedia } from "lib/media"; type IDynamicComponent = Exclude; type IDynamicComponentType = NonNullable; +// HACK - force tailwind to compile sizes for classnames provided to images dynamically +export const ComponentCommonImageSizes = () => { + ; +}; + const ComponentMapping: { [type in IDynamicComponentType]: (block: IDynamicComponent) => JSX.Element } = { ComponentCommonActionButton: (block) => { const { ClassNames, ...rest } = block as ComponentCommonActionButton; @@ -41,17 +46,18 @@ const ComponentMapping: { [type in IDynamicComponentType]: (block: IDynamicCompo

); }, + ComponentCommonImage: (block) => { const { Media, AltText, Caption, ClassNames } = block as ComponentCommonImage; // Wrap image with figure/figcaption when caption provided. Simply return image when not return Caption ? ( -
+
{AltText
{Caption}
diff --git a/frontend/package.json b/frontend/package.json index 427a395a..7e37d3d0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,7 +15,7 @@ "@apollo/client": "^3.8.1", "dayjs": "^1.11.2", "graphql": "^16.6.0", - "next": "13.4.19", + "next": "14.1.4", "pg": "^8.7.3", "react": "18.2.0", "react-dom": "18.2.0", @@ -31,14 +31,13 @@ "@graphql-codegen/typescript-operations": "^2.5.3", "@next/bundle-analyzer": "^12.3.1", "@tailwindcss/typography": "^0.5.4", - "@types/next": "^9.0.0", - "@types/node": "^16.11.56", + "@types/node": "^20", "@types/react": "^18.0.18", "@types/react-dom": "^18.0.4", "autoprefixer": "^10.4.8", "daisyui": "^2.24.0", "dotenv": "^16.0.1", - "next-export-optimize-images": "^3.1.0", + "next-export-optimize-images": "^3.3.0", "postcss": "^8.4.16", "sass": "^1.54.6", "tailwindcss": "^3.1.8", diff --git a/frontend/public/robots.txt b/frontend/public/robots.txt new file mode 100644 index 00000000..ff5d3164 --- /dev/null +++ b/frontend/public/robots.txt @@ -0,0 +1,3 @@ +# To prevent search engines from seeing the site altogether, uncomment the next two lines: +# User-Agent: * +# Disallow: / diff --git a/frontend/public/s-logo.svg b/frontend/public/s-logo.svg new file mode 100644 index 00000000..caa29b1f --- /dev/null +++ b/frontend/public/s-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/src/commands/cli/build-deploy-ssg.ts b/scripts/src/commands/cli/build-deploy-ssg.ts index b49c44e6..e94fff97 100644 --- a/scripts/src/commands/cli/build-deploy-ssg.ts +++ b/scripts/src/commands/cli/build-deploy-ssg.ts @@ -29,11 +29,14 @@ interface IProgramOptions { config: "standalone" | "export"; /** Specify whether to start the backend server during build (default: True)*/ backend?: boolean; + /** Specify environment */ + environment: "string"; } const program = new Command("build"); export default program .description("Build deployment images") + .option("-e --environment ", "Specify environment", "development") .option("-p --preview", "Preview build locally") .option("--no-preview", "Do not preview build locally") .option("-d --deploy", "Deploy build") @@ -72,9 +75,10 @@ class BuildCmd { constructor(private options: IProgramOptions) {} public async run() { let { export: shouldExport, preview: shouldPreview, deploy: shouldDeploy } = this.options; + const { environment } = this.options; // Deployments will always read data from local development server // If wanting to use other data it must first be imported locally - await loadEnv("development"); + await loadEnv(environment, { skipHealthcheck: true }); // Ensure data exported if (shouldExport === undefined) { @@ -82,7 +86,11 @@ class BuildCmd { } if (shouldExport) { console.log(chalk.gray("Ensuring data exported")); - await execa("yarn scripts strapi export -e development", { cwd: PATHS.rootDir, shell: true, stdio: "inherit" }); + await execa(`yarn scripts strapi export -e ${environment}`, { + cwd: PATHS.rootDir, + shell: true, + stdio: "inherit", + }); } this.preBuild(); @@ -159,17 +167,20 @@ class BuildCmd { // use local folder for image hosting which will also use optimised folders env: { NEXT_CONFIG_MODE, + // HACK - when building export need to ensure not dev environment + // https://github.com/vercel/next.js/issues/56481 + NODE_ENV: "production", }, }; } /** - * Copy all public uploads from backend to build directory to include in static site + * Copy all public uploads from data to build directory to include in static site */ private preBuild() { - // Copy all public uploads from backend to build directory to include in static site - const srcDir = resolve(PATHS.dataDir, "public", "uploads"); - const targetDir = resolve(PATHS.frontendDir, "public", "uploads"); + // Copy all public uploads from data to build directory to include in static site + const srcDir = resolve(PATHS.dataDir, "public"); + const targetDir = resolve(PATHS.frontendDir, "public"); // TODO - ideally want to rsync for better caching ensureDirSync(targetDir); emptyDirSync(targetDir); diff --git a/scripts/src/commands/docker/build.ts b/scripts/src/commands/docker/build.ts index 2ac2ac76..b44ca964 100644 --- a/scripts/src/commands/docker/build.ts +++ b/scripts/src/commands/docker/build.ts @@ -110,7 +110,7 @@ class DockerBuildCmd { const dockerRepo = `samicharity`; const tags = [`${dockerRepo}/${imageName}:latest`, `${dockerRepo}/${imageName}:${BASE_TAG}`]; if (includeGCR) { - const gcrRepo = `europe-west2-docker.pkg.dev/sami-website-365718/sami-website-staging`; + const gcrRepo = `europe-west1-docker.pkg.dev/sami-website-365718/sami-website`; tags.push(`${gcrRepo}/${imageName}:latest`); tags.push(`${gcrRepo}/${imageName}:${BASE_TAG}`); } diff --git a/scripts/src/commands/docker/push.ts b/scripts/src/commands/docker/push.ts index 6850f1a9..c40e0688 100644 --- a/scripts/src/commands/docker/push.ts +++ b/scripts/src/commands/docker/push.ts @@ -44,7 +44,7 @@ class DockerRunCmd { for (const image of images) { for (const tag of ["latest", BASE_TAG]) { const imageName = useGCR - ? `europe-west2-docker.pkg.dev/sami-website-365718/sami-website-staging/${image}:${tag}` + ? `europe-west1-docker.pkg.dev/sami-website-365718/sami-website/${image}:${tag}` : `samicharity/${image}:${tag}`; const cmd = `docker push ${imageName}`; console.log(chalk.gray(cmd)); diff --git a/scripts/src/commands/strapi/export/db.ts b/scripts/src/commands/strapi/export/db.ts index d7ae3f41..7e1e263d 100644 --- a/scripts/src/commands/strapi/export/db.ts +++ b/scripts/src/commands/strapi/export/db.ts @@ -7,6 +7,7 @@ import { sortJSONObjectByKey } from "../../../utils/object.utils"; import { getDB, listDBTables, mapDBData } from "../common"; import { replicateDir } from "../../../utils/file.utils"; import { tmpdir } from "os"; +import chalk from "chalk"; /*************************************************************************************** * Main Methods @@ -20,17 +21,19 @@ export class DBExport { public async run(envName: string, envParsed: any) { const gcsBucket = envParsed.GCS_DB_BUCKET_NAME; if (gcsBucket) { - const dbFilename = envParsed.DATABASE_FILENAME; const dbDir = resolve(PATHS.dataDir, "db"); - const targetDB = resolve(dbDir, dbFilename); - // TODO - consider using sdk methods - spawnSync(`gsutil cp -r gs://${gcsBucket}/* ${dbDir}`, { + const cmd = `gcloud storage rsync gs://${gcsBucket} ${dbDir}`; + console.log(chalk.gray(cmd)); + spawnSync(cmd, { shell: true, stdio: "inherit", cwd: PATHS.rootDir, }); + const dbFilename = envParsed.DATABASE_FILENAME; + const targetDB = resolve(dbDir, dbFilename); if (!existsSync(targetDB)) { - throw new Error("DB not exported:\n" + targetDB); + console.warn(`Exported db not found:`, `${dbDir}/${dbFilename}`); + // throw new Error("DB not exported:\n" + `${dbDir}/${dbFilename}`); } } // query list of all tables diff --git a/scripts/src/commands/strapi/export/index.ts b/scripts/src/commands/strapi/export/index.ts index 5a81222d..8e0b9ef7 100644 --- a/scripts/src/commands/strapi/export/index.ts +++ b/scripts/src/commands/strapi/export/index.ts @@ -15,6 +15,7 @@ interface IProgramOptions { environment?: string; /** specify to only import assets or db */ only: (typeof allTargets)[number]; + ci?: boolean; } const allTargets = ["storage", "db"] as const; @@ -23,7 +24,12 @@ export default program .description("Export strapi data") .option("-e --environment ", "Name of environment to use") .option("-o --only ", "List of targets to include", allTargets.join(",")) + .option("-ci --ci", "Disable prompts for CI mode") .action(async (options: IProgramOptions) => { + // force ci environment variable if specified + if (options.ci) { + process.env.CI = "true"; + } const { name, parsed } = await loadEnv(options.environment); const targets = allTargets.filter((t) => options.only.includes(t)); if (targets.includes("db")) { @@ -33,7 +39,7 @@ export default program } if (targets.includes("storage")) { console.log(chalk.blue("Exporting Storage...")); - await new StorageExport().run(parsed.GCS_STORAGE_BUCKET_NAME); + await new StorageExport().run(parsed.GCS_PUBLIC_BUCKET_NAME); console.log(chalk.blue("Storage exported successfully")); } diff --git a/scripts/src/commands/strapi/export/storage.ts b/scripts/src/commands/strapi/export/storage.ts index 17106e54..3742e292 100644 --- a/scripts/src/commands/strapi/export/storage.ts +++ b/scripts/src/commands/strapi/export/storage.ts @@ -2,18 +2,22 @@ import { resolve } from "path"; import { PATHS } from "../../../paths"; import { ensureDirSync } from "fs-extra"; import { spawnSync } from "child_process"; +import chalk from "chalk"; export class StorageExport { public async run(gcsBucketName?: string) { if (gcsBucketName) { return this.exportGoogleStorage(gcsBucketName); } + console.log("Skipped - no gcsBucketName"); // local strapi already writes storage to data dir } private exportGoogleStorage(bucketName: string) { - const outputDir = resolve(PATHS.dataDir, "public", "uploads"); + const outputDir = resolve(PATHS.dataDir, "public"); + const cmd = `gcloud storage rsync gs://${bucketName} "${outputDir}" --recursive`; + console.log(chalk.gray(cmd)); ensureDirSync(outputDir); - spawnSync(`gcloud storage rsync gs://${bucketName} "${outputDir}"`, { + spawnSync(cmd, { shell: true, stdio: "inherit", cwd: PATHS.rootDir, diff --git a/scripts/src/commands/strapi/import/index.ts b/scripts/src/commands/strapi/import/index.ts index d1889f34..058cbdb3 100644 --- a/scripts/src/commands/strapi/import/index.ts +++ b/scripts/src/commands/strapi/import/index.ts @@ -13,6 +13,7 @@ interface IProgramOptions { environment?: string; /** specify to only import assets or db */ only?: "storage" | "db"; + ci?: boolean; } const program = new Command("import"); export default program @@ -20,7 +21,12 @@ export default program .option("-e --environment ", "Name of environment to use)") .option("-o --only ", "Specify 'assets' or 'db' to only import") .option("-t --table ", "Single table to import (omit to include all)") + .option("-ci --ci", "Disable prompts for CI mode") .action(async (options: IProgramOptions) => { + // force ci environment variable if specified + if (options.ci) { + process.env.CI = "true"; + } const { name, parsed } = await loadEnv(options.environment); // Import storage first as db references will be dropped if assets do not exist if (options.only !== "db") { diff --git a/scripts/src/utils/env.utils.ts b/scripts/src/utils/env.utils.ts index 2887b0c0..7d218e59 100644 --- a/scripts/src/utils/env.utils.ts +++ b/scripts/src/utils/env.utils.ts @@ -78,6 +78,8 @@ export async function loadEnv(envName?: string, options: { skipHealthcheck?: boo ...parsed, ...dotenv.config({ path: envLocalOverridesPath, override: true }).parsed, }; + } else { + console.log("No local overrides for env detected", envLocalOverridesPath); } //ensure loaded env configured correctly @@ -172,6 +174,7 @@ async function healthcheck(options: { envParsed?; envName?: string } = {}) { logError({ msg1: "Failed to boostrap Strapi, retry manually", msg2: "yarn scripts strapi boostrap" }); } const bootstrapCmd = `yarn scripts strapi bootstrap -e ${envName}`; + console.log(envName, "STRAPI_READONLY_TOKEN not detected, attempting bootstrap"); console.log(chalk.gray(bootstrapCmd)); await execa(bootstrapCmd, { shell: true, cwd: PATHS.rootDir, stdio: "inherit" }); isHealthcheckRetry = true; diff --git a/yarn.lock b/yarn.lock index bc080476..abf0bddd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2843,142 +2843,72 @@ __metadata: languageName: node linkType: hard -"@next/env@npm:13.4.19": - version: 13.4.19 - resolution: "@next/env@npm:13.4.19" - checksum: 10/9454485caf50292d4b1b4ffdd4794d408a07c43ac3e4688bcca023cd10980232a0a283f6fc48129ae4f3c21ad547b8404beeb84b5e1883815f940cb36a18c2fa +"@next/env@npm:14.1.4": + version: 14.1.4 + resolution: "@next/env@npm:14.1.4" + checksum: 10/76db04d141aed6e4e7f64619f66b84b39a01fd698db735381b530347794b252d74f9d71fe6787402f986a5202e9a4ce1d9c2569fec7c56e67e346c0522883b8b languageName: node linkType: hard -"@next/env@npm:14.1.1": - version: 14.1.1 - resolution: "@next/env@npm:14.1.1" - checksum: 10/af0168783f2eb7ec6eb3475dcc78eb52cb680609111014b3948dfb601193a0aa5536952f90c9e93a823aa23ecb95d9fab71f2cdd436f46703bbeccceebe5e230 - languageName: node - linkType: hard - -"@next/swc-darwin-arm64@npm:13.4.19": - version: 13.4.19 - resolution: "@next/swc-darwin-arm64@npm:13.4.19" - conditions: os=darwin & cpu=arm64 - languageName: node - linkType: hard - -"@next/swc-darwin-arm64@npm:14.1.1": - version: 14.1.1 - resolution: "@next/swc-darwin-arm64@npm:14.1.1" +"@next/swc-darwin-arm64@npm:14.1.4": + version: 14.1.4 + resolution: "@next/swc-darwin-arm64@npm:14.1.4" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@next/swc-darwin-x64@npm:13.4.19": - version: 13.4.19 - resolution: "@next/swc-darwin-x64@npm:13.4.19" +"@next/swc-darwin-x64@npm:14.1.4": + version: 14.1.4 + resolution: "@next/swc-darwin-x64@npm:14.1.4" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@next/swc-darwin-x64@npm:14.1.1": - version: 14.1.1 - resolution: "@next/swc-darwin-x64@npm:14.1.1" - conditions: os=darwin & cpu=x64 - languageName: node - linkType: hard - -"@next/swc-linux-arm64-gnu@npm:13.4.19": - version: 13.4.19 - resolution: "@next/swc-linux-arm64-gnu@npm:13.4.19" +"@next/swc-linux-arm64-gnu@npm:14.1.4": + version: 14.1.4 + resolution: "@next/swc-linux-arm64-gnu@npm:14.1.4" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@next/swc-linux-arm64-gnu@npm:14.1.1": - version: 14.1.1 - resolution: "@next/swc-linux-arm64-gnu@npm:14.1.1" - conditions: os=linux & cpu=arm64 & libc=glibc - languageName: node - linkType: hard - -"@next/swc-linux-arm64-musl@npm:13.4.19": - version: 13.4.19 - resolution: "@next/swc-linux-arm64-musl@npm:13.4.19" +"@next/swc-linux-arm64-musl@npm:14.1.4": + version: 14.1.4 + resolution: "@next/swc-linux-arm64-musl@npm:14.1.4" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@next/swc-linux-arm64-musl@npm:14.1.1": - version: 14.1.1 - resolution: "@next/swc-linux-arm64-musl@npm:14.1.1" - conditions: os=linux & cpu=arm64 & libc=musl - languageName: node - linkType: hard - -"@next/swc-linux-x64-gnu@npm:13.4.19": - version: 13.4.19 - resolution: "@next/swc-linux-x64-gnu@npm:13.4.19" +"@next/swc-linux-x64-gnu@npm:14.1.4": + version: 14.1.4 + resolution: "@next/swc-linux-x64-gnu@npm:14.1.4" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@next/swc-linux-x64-gnu@npm:14.1.1": - version: 14.1.1 - resolution: "@next/swc-linux-x64-gnu@npm:14.1.1" - conditions: os=linux & cpu=x64 & libc=glibc - languageName: node - linkType: hard - -"@next/swc-linux-x64-musl@npm:13.4.19": - version: 13.4.19 - resolution: "@next/swc-linux-x64-musl@npm:13.4.19" - conditions: os=linux & cpu=x64 & libc=musl - languageName: node - linkType: hard - -"@next/swc-linux-x64-musl@npm:14.1.1": - version: 14.1.1 - resolution: "@next/swc-linux-x64-musl@npm:14.1.1" +"@next/swc-linux-x64-musl@npm:14.1.4": + version: 14.1.4 + resolution: "@next/swc-linux-x64-musl@npm:14.1.4" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@next/swc-win32-arm64-msvc@npm:13.4.19": - version: 13.4.19 - resolution: "@next/swc-win32-arm64-msvc@npm:13.4.19" +"@next/swc-win32-arm64-msvc@npm:14.1.4": + version: 14.1.4 + resolution: "@next/swc-win32-arm64-msvc@npm:14.1.4" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@next/swc-win32-arm64-msvc@npm:14.1.1": - version: 14.1.1 - resolution: "@next/swc-win32-arm64-msvc@npm:14.1.1" - conditions: os=win32 & cpu=arm64 - languageName: node - linkType: hard - -"@next/swc-win32-ia32-msvc@npm:13.4.19": - version: 13.4.19 - resolution: "@next/swc-win32-ia32-msvc@npm:13.4.19" +"@next/swc-win32-ia32-msvc@npm:14.1.4": + version: 14.1.4 + resolution: "@next/swc-win32-ia32-msvc@npm:14.1.4" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@next/swc-win32-ia32-msvc@npm:14.1.1": - version: 14.1.1 - resolution: "@next/swc-win32-ia32-msvc@npm:14.1.1" - conditions: os=win32 & cpu=ia32 - languageName: node - linkType: hard - -"@next/swc-win32-x64-msvc@npm:13.4.19": - version: 13.4.19 - resolution: "@next/swc-win32-x64-msvc@npm:13.4.19" - conditions: os=win32 & cpu=x64 - languageName: node - linkType: hard - -"@next/swc-win32-x64-msvc@npm:14.1.1": - version: 14.1.1 - resolution: "@next/swc-win32-x64-msvc@npm:14.1.1" +"@next/swc-win32-x64-msvc@npm:14.1.4": + version: 14.1.4 + resolution: "@next/swc-win32-x64-msvc@npm:14.1.4" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -5141,15 +5071,6 @@ __metadata: languageName: node linkType: hard -"@swc/helpers@npm:0.5.1": - version: 0.5.1 - resolution: "@swc/helpers@npm:0.5.1" - dependencies: - tslib: "npm:^2.4.0" - checksum: 10/4954c4d2dd97bf965e863a10ffa44c3fdaf7653f2fa9ef1a6cf7ffffd67f3f832216588f9751afd75fdeaea60c4688c75c01e2405119c448f1a109c9a7958c54 - languageName: node - linkType: hard - "@swc/helpers@npm:0.5.2": version: 0.5.2 resolution: "@swc/helpers@npm:0.5.2" @@ -5644,15 +5565,6 @@ __metadata: languageName: node linkType: hard -"@types/next@npm:^9.0.0": - version: 9.0.0 - resolution: "@types/next@npm:9.0.0" - dependencies: - next: "npm:*" - checksum: 10/3115931293e1928df5ecd9d0cbf8b9edc9e2d7f67467db468f3d92dac7b44199706dbd4226c33193a7fcd3fe230a1ec2c796a1a585911d40be9fdaf47e8cb16e - languageName: node - linkType: hard - "@types/node@npm:*, @types/node@npm:>=10.0.0": version: 20.11.24 resolution: "@types/node@npm:20.11.24" @@ -5676,13 +5588,6 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^16.11.56": - version: 16.18.86 - resolution: "@types/node@npm:16.18.86" - checksum: 10/a2d4f36698abd0da6ec548d72a154566729b80dbec7cf14ddcc444ced14f483733a29eaa65d4128ffc9720414b2b4d5c35085b9cebfdf8ef43bf644e12c991b9 - languageName: node - linkType: hard - "@types/node@npm:^18.15.11": version: 18.19.21 resolution: "@types/node@npm:18.19.21" @@ -5692,6 +5597,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^20": + version: 20.11.30 + resolution: "@types/node@npm:20.11.30" + dependencies: + undici-types: "npm:~5.26.4" + checksum: 10/78515bc768d2b878e2e06a1c20eb4f5840072b79b8d28ff3dd0a7feaaf48fd3a2ac03cfa5bc7564da82db5906b43e9ba0e5df9f43d870b7aae2942306e208815 + languageName: node + linkType: hard + "@types/normalize-package-data@npm:^2.4.0": version: 2.4.4 resolution: "@types/normalize-package-data@npm:2.4.4" @@ -8165,7 +8079,7 @@ __metadata: languageName: node linkType: hard -"caniuse-lite@npm:^1.0.30001406, caniuse-lite@npm:^1.0.30001579, caniuse-lite@npm:^1.0.30001587, caniuse-lite@npm:^1.0.30001591": +"caniuse-lite@npm:^1.0.30001579, caniuse-lite@npm:^1.0.30001587, caniuse-lite@npm:^1.0.30001591": version: 1.0.30001591 resolution: "caniuse-lite@npm:1.0.30001591" checksum: 10/3891fad30a99b984a3a20570c0440d35dda933c79ea190cdb78a1f1743866506a4b41b4389b53a7c0351f2228125f9dc49308463f57e61503e5689b444add1a8 @@ -12032,8 +11946,7 @@ __metadata: "@graphql-codegen/typescript-operations": "npm:^2.5.3" "@next/bundle-analyzer": "npm:^12.3.1" "@tailwindcss/typography": "npm:^0.5.4" - "@types/next": "npm:^9.0.0" - "@types/node": "npm:^16.11.56" + "@types/node": "npm:^20" "@types/react": "npm:^18.0.18" "@types/react-dom": "npm:^18.0.4" autoprefixer: "npm:^10.4.8" @@ -12041,8 +11954,8 @@ __metadata: dayjs: "npm:^1.11.2" dotenv: "npm:^16.0.1" graphql: "npm:^16.6.0" - next: "npm:13.4.19" - next-export-optimize-images: "npm:^3.1.0" + next: "npm:14.1.4" + next-export-optimize-images: "npm:^3.3.0" pg: "npm:^8.7.3" postcss: "npm:^8.4.16" react: "npm:18.2.0" @@ -12117,7 +12030,7 @@ __metadata: languageName: node linkType: hard -"fs-extra@npm:^11.1.1": +"fs-extra@npm:^11.1.1, fs-extra@npm:^11.2.0": version: 11.2.0 resolution: "fs-extra@npm:11.2.0" dependencies: @@ -16467,7 +16380,7 @@ __metadata: languageName: node linkType: hard -"nanoid@npm:^3.3.4, nanoid@npm:^3.3.6, nanoid@npm:^3.3.7": +"nanoid@npm:^3.3.6, nanoid@npm:^3.3.7": version: 3.3.7 resolution: "nanoid@npm:3.3.7" bin: @@ -16530,42 +16443,42 @@ __metadata: languageName: node linkType: hard -"next-export-optimize-images@npm:^3.1.0": - version: 3.2.0 - resolution: "next-export-optimize-images@npm:3.2.0" +"next-export-optimize-images@npm:^3.3.0": + version: 3.3.0 + resolution: "next-export-optimize-images@npm:3.3.0" dependencies: ansi-colors: "npm:^4.1.3" app-root-path: "npm:^3.1.0" cli-progress: "npm:^3.12.0" - fs-extra: "npm:^11.1.1" + fs-extra: "npm:^11.2.0" got: "npm:^11.8.6" lodash.uniqwith: "npm:^4.5.0" recursive-readdir: "npm:^2.2.3" - sharp: "npm:^0.32.5" + sharp: "npm:^0.32.6" peerDependencies: next: ">=13.0.0" react: ^17.0.2 || ^18.0.0-0 react-dom: ^17.0.2 || ^18.0.0-0 bin: next-export-optimize-images: bin/index.js - checksum: 10/f6c597bbfa38d730c49a069c4e8fe5f9b882dd1535a838da3352d5a7d9e1d72c281688a9a4d6f05ad816b3fcfc4ca4069670281407e79bb3369b6c04a80a3ad9 + checksum: 10/123a06204afc0f9bf7b3ba987d4dfa0e11f391b9790c46a08054d6e23ab6cf498a0e9614dc9e9c0a8c05a46b69d44e44de5ae533e047b10a1991d7c2987cdb36 languageName: node linkType: hard -"next@npm:*": - version: 14.1.1 - resolution: "next@npm:14.1.1" +"next@npm:14.1.4": + version: 14.1.4 + resolution: "next@npm:14.1.4" dependencies: - "@next/env": "npm:14.1.1" - "@next/swc-darwin-arm64": "npm:14.1.1" - "@next/swc-darwin-x64": "npm:14.1.1" - "@next/swc-linux-arm64-gnu": "npm:14.1.1" - "@next/swc-linux-arm64-musl": "npm:14.1.1" - "@next/swc-linux-x64-gnu": "npm:14.1.1" - "@next/swc-linux-x64-musl": "npm:14.1.1" - "@next/swc-win32-arm64-msvc": "npm:14.1.1" - "@next/swc-win32-ia32-msvc": "npm:14.1.1" - "@next/swc-win32-x64-msvc": "npm:14.1.1" + "@next/env": "npm:14.1.4" + "@next/swc-darwin-arm64": "npm:14.1.4" + "@next/swc-darwin-x64": "npm:14.1.4" + "@next/swc-linux-arm64-gnu": "npm:14.1.4" + "@next/swc-linux-arm64-musl": "npm:14.1.4" + "@next/swc-linux-x64-gnu": "npm:14.1.4" + "@next/swc-linux-x64-musl": "npm:14.1.4" + "@next/swc-win32-arm64-msvc": "npm:14.1.4" + "@next/swc-win32-ia32-msvc": "npm:14.1.4" + "@next/swc-win32-x64-msvc": "npm:14.1.4" "@swc/helpers": "npm:0.5.2" busboy: "npm:1.6.0" caniuse-lite: "npm:^1.0.30001579" @@ -16603,63 +16516,7 @@ __metadata: optional: true bin: next: dist/bin/next - checksum: 10/33524d993a184c8922a1077502c165873dd4f07b5f75664ab2743fe045d699a6b3edddd29ab1cdb187ed648961773bd3f4d5b96860e78f14d7c5a4730a9d35d5 - languageName: node - linkType: hard - -"next@npm:13.4.19": - version: 13.4.19 - resolution: "next@npm:13.4.19" - dependencies: - "@next/env": "npm:13.4.19" - "@next/swc-darwin-arm64": "npm:13.4.19" - "@next/swc-darwin-x64": "npm:13.4.19" - "@next/swc-linux-arm64-gnu": "npm:13.4.19" - "@next/swc-linux-arm64-musl": "npm:13.4.19" - "@next/swc-linux-x64-gnu": "npm:13.4.19" - "@next/swc-linux-x64-musl": "npm:13.4.19" - "@next/swc-win32-arm64-msvc": "npm:13.4.19" - "@next/swc-win32-ia32-msvc": "npm:13.4.19" - "@next/swc-win32-x64-msvc": "npm:13.4.19" - "@swc/helpers": "npm:0.5.1" - busboy: "npm:1.6.0" - caniuse-lite: "npm:^1.0.30001406" - postcss: "npm:8.4.14" - styled-jsx: "npm:5.1.1" - watchpack: "npm:2.4.0" - zod: "npm:3.21.4" - peerDependencies: - "@opentelemetry/api": ^1.1.0 - react: ^18.2.0 - react-dom: ^18.2.0 - sass: ^1.3.0 - dependenciesMeta: - "@next/swc-darwin-arm64": - optional: true - "@next/swc-darwin-x64": - optional: true - "@next/swc-linux-arm64-gnu": - optional: true - "@next/swc-linux-arm64-musl": - optional: true - "@next/swc-linux-x64-gnu": - optional: true - "@next/swc-linux-x64-musl": - optional: true - "@next/swc-win32-arm64-msvc": - optional: true - "@next/swc-win32-ia32-msvc": - optional: true - "@next/swc-win32-x64-msvc": - optional: true - peerDependenciesMeta: - "@opentelemetry/api": - optional: true - sass: - optional: true - bin: - next: dist/bin/next - checksum: 10/e5180f07d5d0fd8603ae6f57966c8051a67c69cc07f1d472f1947c82dd1961ec2d57480012f234101f9a0ac90c85839798972efe9b91512417f34db0d2dcbf29 + checksum: 10/16dd0667d55caf0b9915c530e4ae950ae7fad42c22573f333cd23f2fee8243afa4d3e8093a1c7d07251ced150c0bed9cde273cac951b919594a8e2112d669266 languageName: node linkType: hard @@ -18278,17 +18135,6 @@ __metadata: languageName: node linkType: hard -"postcss@npm:8.4.14": - version: 8.4.14 - resolution: "postcss@npm:8.4.14" - dependencies: - nanoid: "npm:^3.3.4" - picocolors: "npm:^1.0.0" - source-map-js: "npm:^1.0.2" - checksum: 10/1940e8d1da04a2ac3e518735ab3e9563e2255bfab14cecc8c11fee97b2a36ac5fee496bccfc7057aaae7ff3accae463cd800d746238cf691bd65a32dba5cb7be - languageName: node - linkType: hard - "postcss@npm:8.4.31": version: 8.4.31 resolution: "postcss@npm:8.4.31" @@ -20236,7 +20082,7 @@ __metadata: languageName: node linkType: hard -"sharp@npm:0.32.6, sharp@npm:^0.32.0, sharp@npm:^0.32.5": +"sharp@npm:0.32.6, sharp@npm:^0.32.0, sharp@npm:^0.32.6": version: 0.32.6 resolution: "sharp@npm:0.32.6" dependencies: @@ -22945,7 +22791,7 @@ __metadata: languageName: node linkType: hard -"watchpack@npm:2.4.0, watchpack@npm:^2.4.0": +"watchpack@npm:^2.4.0": version: 2.4.0 resolution: "watchpack@npm:2.4.0" dependencies: @@ -23678,10 +23524,3 @@ __metadata: checksum: 10/30eac3f4055d33f446b4cd075d3543da347c2c8e68fbc35c3f5a19fb43be67c6ed27ee136bc8f8933efa547be7ce04957809ad00ee7f1b00a964f199ae6fb514 languageName: node linkType: hard - -"zod@npm:3.21.4": - version: 3.21.4 - resolution: "zod@npm:3.21.4" - checksum: 10/03c79fa4610a35e24119771970be764c6e177a271a225587f86a7fc35d55e94a154d8e1970d23ffe35b567c147262bedbcb53b31aa30eeef2493fbd13e1b4aca - languageName: node - linkType: hard