Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move scripts and migrations out of src #2706

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/collaborating.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The Website also uses several other Open Source libraries (not limited to) liste
- Multi-Purpose JavaScript functions are defined on `/src/utilities`
- Multi-Purpose TypeScript definitions are defined on `/src/types`
- Centralized data collections are defined in `/src/data`
- Multi-Purpose Scripts are stored within `/src/scripts`
- Multi-Purpose Scripts are stored within `/scripts`
- Such as link validation

### Adding new Astro pages
Expand Down Expand Up @@ -207,7 +207,7 @@ It is used for defining redirects. (Such as Internal Redirects and External ones

Redirect operations change the original URL to a new one.

Please run [/src/scripts/format-redirect.mjs](./src/scripts/format-redirect.mjs) after making changes to this file to preserve the formatting.
Please run [/scripts/format-redirect.mjs](./scripts/format-redirect.mjs) after making changes to this file to preserve the formatting.

#### What is `/public/_headers`?

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.redirects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
npm run build

- name: 📦 Install Script Dependencies
working-directory: ./src/scripts
working-directory: ./scripts
run: |
npm install

Expand All @@ -48,7 +48,7 @@ jobs:
id: validate
with:
command: node validate-redirects.mjs
cwd: ./src/scripts
cwd: ./scripts

- name: ✍️ Updating PR Comment
uses: thollander/actions-comment-pull-request@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/schedule.sgid-index-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/scripts
working-directory: ./scripts
env:
GOOGLE_PRIVATE_KEY: ${{ secrets.SA }}
RESULTS_COMMENT_TITLE: SGID Index Validation
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
id: validate
with:
command: node validate-sgid-index.mjs
cwd: ./src/scripts
cwd: ./scripts

- name: 📝 Create issue
id: create-issue
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const parsePagesForLinks = async (lookup) => {
'dist',
'downloads',
'node_modules',
'src/migrations',
'migrations',
'src/layouts',
'src/images',
'src/components',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "astro preview",
"start": "astro dev",
"ts-check": "astro check --minimumSeverity=warning",
"validate-site-map": "cd src/scripts && node ./validate-site-map.mjs"
"validate-site-map": "cd scripts && node ./validate-site-map.mjs"
},
"prettier": {
"printWidth": 120,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { open } from 'node:fs/promises';
import { join } from 'node:path';

const redirectPath = join('..', '..', 'public', '_redirects');
const redirectPath = join('..', 'public', '_redirects');
const readFile = await open(redirectPath, 'r');

function standardize(url) {
Expand Down
33 changes: 33 additions & 0 deletions scripts/new-blog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fs from 'fs';

// e.g. node scripts/new-blog.mjs "Blog Title"

const title = process.argv[2];
const date = new Date().toISOString().split('T')[0];
const slug = `${date}-${title.toLowerCase().replace(/\s+/g, '-')}`;
const filePath = `../src/content/blog/${slug}.mdx`;
const folderPath = `../src/images/pillar-blog/${slug}`;

const data = `---
title: ${title}
author: Steve Gourley
description: 100-160 character description of the blog post
date: ${new Date().toISOString()}
category: UGRC
tags:
- website
cover_image: /src/images/pillar-blog/default-social-card.png
cover_image_alt: ugrc social card
---

import { Image } from 'astro:assets';

import myImage from \`@images/blog/${slug}/image.png\`;

My blog post content starts here.

<Image src={myImage} loading="eager" alt="A sample image" />
`;

fs.writeFileSync(filePath, data, 'utf-8');
fs.mkdirSync(folderPath);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { open } from 'node:fs/promises';
import { join } from 'node:path';
import { validateUrl } from './utilities.mjs';

const redirectPath = join('..', '..', 'public', '_redirects');
const redirectPath = join('..', 'public', '_redirects');
let file = await open(redirectPath, 'r');

// get urls from built files
const fileUrls = globSync('../../dist/**/*.html', { ignore: '../../dist/404.html' }).map((path) =>
const fileUrls = globSync('../dist/**/*.html', { ignore: '../dist/404.html' }).map((path) =>
path
.replace('../../dist', '')
.replace('../dist', '')
.replace(/index\.html$/, '')
.replace(/\/$/, ''),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as tsImport from 'ts-import';
import { v4 as uuid } from 'uuid';
import { validateOpenDataUrl, validateOpenSgidTableName, validateUrl } from './utilities.mjs';

const downloadMetadata = await tsImport.load('../data/downloadMetadata.ts');
const downloadMetadata = await tsImport.load('../src/data/downloadMetadata.ts');

const spreadsheetId = '11ASS7LnxgpnD0jN4utzklREgMf1pcvYjcXcIcESHweQ';
const ourWebSite = 'https://gis.utah.gov';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { XMLParser } from 'fast-xml-parser';
import { readFileSync } from 'fs';
import { globSync } from 'glob';

const siteMapPath = '../../dist/sitemap-0.xml';
const siteMapPath = '../dist/sitemap-0.xml';

const parser = new XMLParser();

Expand All @@ -11,8 +11,8 @@ const siteMap = parser.parse(readFileSync(siteMapPath, 'utf8'));
const siteMapUrls = siteMap.urlset.url.map((node) => node.loc);

// get urls from built files
const fileUrls = globSync('../../dist/**/*.html', { ignore: '../../dist/404.html' }).map((path) =>
path.replace('../../dist', 'https://gis.utah.gov').replace(/index\.html$/, ''),
const fileUrls = globSync('../dist/**/*.html', { ignore: '../dist/404.html' }).map((path) =>
path.replace('../dist', 'https://gis.utah.gov').replace(/index\.html$/, ''),
);

const fileUrlsNotInSiteMap = fileUrls.filter((url) => !siteMapUrls.includes(url));
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
],
"exclude": [
"dist",
"src/migrations",
"src/scripts",
"migrations",
"scripts",
"src/data/downloadMetadata.ts"
]
}