mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-15 06:35:20 -07:00
Keep device listings available in clean builds
The Netlify validation job imports site listings before generated static device JSON exists in a clean checkout, so keep the small device table in tracked source and use it as the route fallback. Constraint: static/device-list.json is ignored generated output and is absent in GitHub-hosted clean runners Rejected: Force-add static/device-list.json | keeps generated output under source control Confidence: high Scope-risk: narrow Directive: Keep disabled device rows in the fallback source but filter them from routable listings Tested: pnpm run with-env vitest ./test/prebuild/site-listings.test.js Tested: pnpm netlify-build reached Astro build after passing prebuild tests Not-tested: Full local netlify-build completion blocked by unrelated uncommitted scanner worker build failure
This commit is contained in:
parent
3d19c60670
commit
d1f49267c0
3 changed files with 142 additions and 7 deletions
136
helpers/device-list-fallbacks.js
Normal file
136
helpers/device-list-fallbacks.js
Normal file
|
|
@ -0,0 +1,136 @@
|
||||||
|
const rawDeviceList = [
|
||||||
|
{
|
||||||
|
name: '2023 M3 Macbook Pros',
|
||||||
|
enabled: 'yes',
|
||||||
|
type: 'mac-apple-silicon',
|
||||||
|
description: '16 inch and 14 inch M3 Max Macbook Pro designed for pros. ',
|
||||||
|
amazonUrl: 'https://www.apple.com/macbook-pro/',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: '2023-m3-macbook-pros',
|
||||||
|
endpoint: '/device/2023-m3-macbook-pros'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '2023 M2 Macbook Pros',
|
||||||
|
enabled: 'yes',
|
||||||
|
type: 'mac-apple-silicon',
|
||||||
|
description: '16 inch and 14 inch M2 Max Macbook Pro designed for pros. ',
|
||||||
|
amazonUrl: 'https://amzn.to/3FEuUs1',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: '2023-m2-macbook-pros',
|
||||||
|
endpoint: '/device/2023-m2-macbook-pros'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '2023 M3 iMac',
|
||||||
|
enabled: 'yes',
|
||||||
|
type: 'mac-apple-silicon',
|
||||||
|
description: 'M3 iMac is the new Apple Silicon desktop optimized with the Apple M3 processor. ',
|
||||||
|
amazonUrl: 'https://www.apple.com/imac/',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: '2023-m3-imac',
|
||||||
|
endpoint: '/device/2023-m3-imac'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '2023 M2 Pro Mac Mini',
|
||||||
|
enabled: 'yes',
|
||||||
|
type: 'mac-apple-silicon',
|
||||||
|
description: 'M3 Mac Mini is the second generation Apple Silicon iMac for desktop.',
|
||||||
|
amazonUrl: 'https://amzn.to/40yxCsV',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: '2023-m2-pro-mac-mini',
|
||||||
|
endpoint: '/device/2023-m2-pro-mac-mini'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Intel Macs',
|
||||||
|
enabled: 'yes',
|
||||||
|
type: 'intel',
|
||||||
|
description: 'Intel Macs are the classic Macs that succeed the PowerPC Macs and preceeded Apple Silicon. ',
|
||||||
|
amazonUrl: 'https://amzn.to/3h3LQwR',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: 'intel-macs',
|
||||||
|
endpoint: '/device/intel-macs'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'iPad',
|
||||||
|
enabled: 'no',
|
||||||
|
type: 'ios',
|
||||||
|
description: '',
|
||||||
|
amazonUrl: 'https://amzn.to/3b67Inz',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: 'ipad',
|
||||||
|
endpoint: '/device/ipad'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'iPhone',
|
||||||
|
enabled: 'no',
|
||||||
|
type: 'ios',
|
||||||
|
description: '',
|
||||||
|
amazonUrl: 'https://amzn.to/3uovRxs',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: 'iphone',
|
||||||
|
endpoint: '/device/iphone'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '2021 M1 Macbook Pros',
|
||||||
|
enabled: 'no',
|
||||||
|
type: 'mac-apple-silicon',
|
||||||
|
description: 'M1 Pro Macbook Pro and M1 Max Macbook Pro are the new Apple Silicon notebooks optimized with the Apple M1 processor and the first Apple silicon designed for pros. ',
|
||||||
|
amazonUrl: 'https://amzn.to/3jiwNQh',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: '2021-m1-macbook-pros',
|
||||||
|
endpoint: '/device/2021-m1-macbook-pros'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'M1 Macbook Pro',
|
||||||
|
enabled: 'no',
|
||||||
|
type: 'mac-apple-silicon',
|
||||||
|
description: 'M1 Macbook Pro is the portable first generation Apple Silicon Mac for professionals.',
|
||||||
|
amazonUrl: 'https://amzn.to/3h3BkG1',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: 'm1-macbook-pro',
|
||||||
|
endpoint: '/device/m1-macbook-pro'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'M1 Macbook Air',
|
||||||
|
enabled: 'no',
|
||||||
|
type: 'mac-apple-silicon',
|
||||||
|
description: 'M1 Macbook Air is the portable first generation Apple Silicon Mac for users needing a lighter computer.',
|
||||||
|
amazonUrl: 'https://amzn.to/3elKVX5',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: 'm1-macbook-air',
|
||||||
|
endpoint: '/device/m1-macbook-air'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'M1 iPad Pro',
|
||||||
|
enabled: 'no',
|
||||||
|
type: 'ios',
|
||||||
|
description: 'M1 iPad Pro is the first mobile Apple device featuring the M1 Apple processor. ',
|
||||||
|
amazonUrl: 'https://amzn.to/3nQY3qe',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: 'm1-ipad-pro',
|
||||||
|
endpoint: '/device/m1-ipad-pro'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'M1 iMac',
|
||||||
|
enabled: 'no',
|
||||||
|
type: 'mac-apple-silicon',
|
||||||
|
description: 'M1 iMac is the new Apple Silicon desktop optimized with the Apple M1 processor and the first of the second generation of Apple Silicon Macs. ',
|
||||||
|
amazonUrl: 'https://amzn.to/3vMUnbA',
|
||||||
|
bhUrl: '',
|
||||||
|
adoramaUrl: '',
|
||||||
|
slug: 'm1-imac',
|
||||||
|
endpoint: '/device/m1-imac'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const deviceListingFallbacks = rawDeviceList.filter( device => device.enabled !== 'no' )
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
import deviceListText from '~/static/device-list.json?raw'
|
|
||||||
import videoListingsText from '~/static/api/youtube-video-listings.json?raw'
|
import videoListingsText from '~/static/api/youtube-video-listings.json?raw'
|
||||||
|
|
||||||
const trailingCommaPattern = /,\s*([\]}])/g
|
import { deviceListingFallbacks } from './device-list-fallbacks.js'
|
||||||
const parsedDeviceList = JSON.parse( deviceListText.replace( trailingCommaPattern, '$1' ) )
|
|
||||||
const parsedVideoListings = JSON.parse( videoListingsText )
|
const parsedVideoListings = JSON.parse( videoListingsText )
|
||||||
|
|
||||||
export function getDeviceListingBySlug ( slug ) {
|
export function getDeviceListingBySlug ( slug ) {
|
||||||
return parsedDeviceList.find( device => device.slug === slug ) || null
|
return deviceListingFallbacks.find( device => device.slug === slug ) || null
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getVideoListingBySlug ( slug ) {
|
export async function getVideoListingBySlug ( slug ) {
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ import {
|
||||||
|
|
||||||
describe( 'site listing fallbacks', () => {
|
describe( 'site listing fallbacks', () => {
|
||||||
it( 'loads known devices from the bundled device list', () => {
|
it( 'loads known devices from the bundled device list', () => {
|
||||||
expect( getDeviceListingBySlug( 'm1-imac' ) ).toMatchObject({
|
expect( getDeviceListingBySlug( '2023-m3-imac' ) ).toMatchObject({
|
||||||
name: 'M1 iMac',
|
name: '2023 M3 iMac',
|
||||||
endpoint: '/device/m1-imac'
|
endpoint: '/device/2023-m3-imac'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue