Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Add extension sample list page #7029

Merged
merged 40 commits into from Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
101897e
Add new sass file
daidr Jul 25, 2023
e0acbdb
Update toc
daidr Jul 26, 2023
0556a8b
Update rollup config
daidr Jul 30, 2023
9911759
Add testdata for extension-samples
daidr Jul 31, 2023
235e864
Add extension samples external data flow
daidr Jul 31, 2023
6ae5469
Init extension samples external data builder
daidr Jul 31, 2023
07d0742
Add extension samples list i18n file
daidr Jul 31, 2023
999919a
Init extension samples list style
daidr Jul 31, 2023
d5cf149
Add samples page layout
daidr Jul 31, 2023
78b8e0a
Update page layout
daidr Jul 31, 2023
27f6540
Update layout
daidr Jul 31, 2023
b81d8ed
Add permission filter
daidr Jul 31, 2023
4b25c7f
Update layout
daidr Aug 1, 2023
7d23598
Update filter
daidr Aug 1, 2023
1edb4d4
Update code
daidr Aug 3, 2023
b681f91
Add adm-zip
daidr Aug 3, 2023
e5a40ea
Update package-lock.json
daidr Aug 3, 2023
e0f0464
Add external build script
daidr Aug 3, 2023
ef1a747
Update style
daidr Aug 4, 2023
9ed19b4
Update i18n
daidr Aug 4, 2023
44ea5bc
Add type definitions
daidr Aug 4, 2023
4a0cbfc
Add used api pills
daidr Aug 4, 2023
682f0ab
Update style
daidr Aug 4, 2023
5430e91
Update site/_includes/partials/sample-item.njk
daidr Aug 10, 2023
d2ed65d
Sort artifacts by date
daidr Aug 10, 2023
547447c
Remove read more button
daidr Aug 10, 2023
ec8a530
Add newline
daidr Aug 10, 2023
0e939cc
Update margins
daidr Aug 10, 2023
e9b0915
Change function name
daidr Aug 10, 2023
6c5595d
Update type definitions
daidr Aug 10, 2023
3b55a3b
Update hero card style
daidr Aug 10, 2023
d35808d
Remove IIFE
daidr Aug 10, 2023
4efd884
Update locale
daidr Aug 12, 2023
4492444
Remove unnecessary style tag
daidr Aug 12, 2023
94b8497
Pin deps versions
daidr Aug 12, 2023
c9c630e
Rename sample-item template
daidr Aug 12, 2023
adeba5d
Remove nested loop
daidr Aug 12, 2023
4480490
Add IGNORED_SAMPLES to hide specified samples
daidr Aug 16, 2023
7a20eba
Update file structure
daidr Aug 17, 2023
073e642
Merge branch 'main' into daidr/samples-list
matthiasrohmer Aug 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 67 additions & 0 deletions external/build/extension-samples.js
@@ -0,0 +1,67 @@
/**
* @fileoverview Fetches chrome extension samples list from GitHub artifacts
* and writes to storage.
* https://github.com/GoogleChrome/chrome-extensions-samples
*/
daidr marked this conversation as resolved.
Show resolved Hide resolved

const {
getGitHubApiClient,
} = require('../../gulp-tasks/stageGitHub/lib/gitHubApi.js');
const AdmZip = require('adm-zip');
const fs = require('fs');
const path = require('path');

const REPO_OWNER = 'GoogleChrome';
const REPO_NAME = 'chrome-extensions-samples';

async function run() {
const client = await getGitHubApiClient();

const response = await client.request(
`GET /repos/${REPO_OWNER}/${REPO_NAME}/actions/artifacts`
);

if (response.status !== 200) {
throw new Error(
`Could not fetch artifacts. Status code: ${response.status}`
);
}

const artifacts = response.data.artifacts.filter(
artifact => artifact.name === 'extension-samples.json' && !artifact.expired
);

if (!artifacts.length) {
throw new Error('No artifacts found.');
}

const sortedArtifacts = artifacts.sort((a, b) => {
return new Date(b.created_at).getTime() - new Date(a.created_at).getTime();
});

const latestArtifactId = sortedArtifacts[0].id;

const artifactResponse = await client.request(
`GET /repos/${REPO_OWNER}/${REPO_NAME}/actions/artifacts/${latestArtifactId}/zip`
);

if (artifactResponse.status !== 200) {
throw new Error(
`Could not fetch artifact data. Status code: ${artifactResponse.status}`
);
}

const zip = new AdmZip(Buffer.from(artifactResponse.data));

const zipEntries = zip
.getEntries()
.filter(entry => entry.entryName === 'extension-samples.json')
.map(entry => entry.getData());

fs.writeFileSync(
path.join(__dirname, '../data/extension-samples.json'),
zipEntries[0]
);
}

run();