From 3e9e35705ed94ef31acb893fb8a690884b9cbd80 Mon Sep 17 00:00:00 2001 From: Pooh5821 Date: Sun, 6 Apr 2025 17:54:54 +0700 Subject: [PATCH 1/8] update app.js and app.test.js --- src/app.js | 40 +++++++++++++++++++++++++++++++++------- src/app.test.js | 16 ++++++++++------ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/app.js b/src/app.js index a8bf206..7ca9261 100644 --- a/src/app.js +++ b/src/app.js @@ -1,13 +1,39 @@ const dayOfTheWeek = (date = new Date()) => { - const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + const days = [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + ]; - return days[date.getDay()]; -} + return days[date.getDay()]; +}; +const monthOfTheYear = (date = new Date()) => { + const months = [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December", + ]; + return months[date.getMonth()]; +}; try { - document.getElementById('day').innerText = dayOfTheWeek(); -} catch(err) {} + document.getElementById("day").innerText = dayOfTheWeek(); + document.getElementById("month").innerText = monthOfTheYear(); +} catch (err) {} - -exports.dayOfTheWeek = dayOfTheWeek; \ No newline at end of file +exports.dayOfTheWeek = dayOfTheWeek; +exports.monthOfTheYear = monthOfTheYear; diff --git a/src/app.test.js b/src/app.test.js index ac1e73a..c94aadc 100644 --- a/src/app.test.js +++ b/src/app.test.js @@ -1,7 +1,11 @@ -const { dayOfTheWeek } = require('./app'); +const { dayOfTheWeek } = require("./app"); +const { monthOfTheYear } = require("./app"); - -test('getDay returns the long-format day of the week', () => { - const day = dayOfTheWeek( new Date('3/11/2020') ); - expect( day ).toBe('Wednesday'); -}); \ No newline at end of file +test("getDay returns the long-format day of the week", () => { + const day = dayOfTheWeek(new Date("3/11/2020")); + expect(day).toBe("Wednesday"); +}); +test("getDay returns the month of the year", () => { + const month = monthOfTheYear(new Date("3/11/2020")); + expect(month).toBe("November"); +}); From d643c17b9d4578b0fc65a4eb658b7a2fe419fcdb Mon Sep 17 00:00:00 2001 From: Pooh5821 Date: Sun, 6 Apr 2025 18:00:16 +0700 Subject: [PATCH 2/8] Fixed test --- src/app.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.test.js b/src/app.test.js index c94aadc..8ebe71f 100644 --- a/src/app.test.js +++ b/src/app.test.js @@ -7,5 +7,5 @@ test("getDay returns the long-format day of the week", () => { }); test("getDay returns the month of the year", () => { const month = monthOfTheYear(new Date("3/11/2020")); - expect(month).toBe("November"); + expect(month).toBe("March"); }); From b06117e25c4a091ae21510f7b6bb5cd9dc2e3034 Mon Sep 17 00:00:00 2001 From: Pooh5821 Date: Sun, 6 Apr 2025 18:11:12 +0700 Subject: [PATCH 3/8] Fixed config --- config.js | 3 +++ package.json | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 config.js diff --git a/config.js b/config.js new file mode 100644 index 0000000..f1cce85 --- /dev/null +++ b/config.js @@ -0,0 +1,3 @@ +const crypto = require('crypto'); +const crypto_orig_createHash = crypto.createHash; +crypto.createHash = algorithm => crypto_orig_createHash(algorithm === 'md4' ? 'sha256' : algorithm); \ No newline at end of file diff --git a/package.json b/package.json index 2726b49..5df0104 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "test": "jest", - "build": "webpack src/app.js -o public/bundle.js", + "build": "set NODE_OPTIONS=--openssl-legacy-provider && webpack --config config.js src/app.js -o public/bundle.js", + "start": "set NODE_OPTIONS=--openssl-legacy-provider", "deploy": "firebase deploy --token \"$FIREBASE_TOKEN\" --only hosting" }, "keywords": [], From a323faeb41db7d78cbed52cbd41f7618388e4c01 Mon Sep 17 00:00:00 2001 From: Pooh5821 <123242180+Pooh5821@users.noreply.github.com> Date: Sun, 6 Apr 2025 18:44:50 +0700 Subject: [PATCH 4/8] Update integrate.yml --- .github/workflows/integrate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index 2a75c87..894b95b 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -22,4 +22,4 @@ jobs: - run: npm ci - run: npm publish env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} From f7229f8fea8785a91b816377254ebd7673ae8e6e Mon Sep 17 00:00:00 2001 From: Pooh5821 Date: Sun, 6 Apr 2025 18:48:33 +0700 Subject: [PATCH 5/8] update secret token --- .github/workflows/integrate.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index 2a75c87..7b59690 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -5,8 +5,7 @@ name: Node Continuous Integration on: pull_request: - branches: [ main ] - + branches: [main] jobs: test_pull_request: @@ -22,4 +21,4 @@ jobs: - run: npm ci - run: npm publish env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}} From a5f9460d4a7ff9082f8e99fa793c8ba9efde41e4 Mon Sep 17 00:00:00 2001 From: Pooh5821 Date: Sun, 6 Apr 2025 18:55:52 +0700 Subject: [PATCH 6/8] fix integrate --- .github/workflows/integrate.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index 7b59690..1406dce 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -15,10 +15,11 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 21 + registry-url: "https://registry.npmjs.org/" - run: npm ci - run: npm test - run: npm run build - - run: npm ci + - run: npm install - run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}} From c3c7ee591a16f64a2620d41da52fcf749db2a096 Mon Sep 17 00:00:00 2001 From: Pooh5821 Date: Sun, 6 Apr 2025 19:01:19 +0700 Subject: [PATCH 7/8] change name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5df0104..5781494 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "devops", + "name": "devops-5821", "version": "1.0.0", "description": "", "main": "index.js", From 2206ba9acd6b81e8f6abf1bf93d2cbcf3cb04193 Mon Sep 17 00:00:00 2001 From: Pooh5821 Date: Sun, 6 Apr 2025 19:11:53 +0700 Subject: [PATCH 8/8] setup deployment --- .github/workflows/firebase-hosting-merge.yml | 20 ++++++++ .../firebase-hosting-pull-request.yml | 21 ++++++++ firebase-debug.log | 49 ------------------- 3 files changed, 41 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/firebase-hosting-merge.yml create mode 100644 .github/workflows/firebase-hosting-pull-request.yml delete mode 100644 firebase-debug.log diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..30963b4 --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,20 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on merge +on: + push: + branches: + - main +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm ci && npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_GITHUBACTIONPRACTICE_F87C3 }} + channelId: live + projectId: githubactionpractice-f87c3 diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..fcc3ba3 --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,21 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on PR +on: pull_request +permissions: + checks: write + contents: read + pull-requests: write +jobs: + build_and_preview: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm ci && npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_GITHUBACTIONPRACTICE_F87C3 }} + projectId: githubactionpractice-f87c3 diff --git a/firebase-debug.log b/firebase-debug.log deleted file mode 100644 index d76f8df..0000000 --- a/firebase-debug.log +++ /dev/null @@ -1,49 +0,0 @@ -[debug] [2025-04-06T10:39:45.633Z] ---------------------------------------------------------------------- -[debug] [2025-04-06T10:39:45.635Z] Command: C:\Program Files\nodejs\node.exe C:\Users\Pooh5821\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js emulators:start -[debug] [2025-04-06T10:39:45.635Z] CLI Version: 14.1.0 -[debug] [2025-04-06T10:39:45.636Z] Platform: win32 -[debug] [2025-04-06T10:39:45.636Z] Node Version: v22.13.0 -[debug] [2025-04-06T10:39:45.636Z] Time: Sun Apr 06 2025 17:39:45 GMT+0700 (Indochina Time) -[debug] [2025-04-06T10:39:45.636Z] ---------------------------------------------------------------------- -[debug] -[debug] [2025-04-06T10:39:45.828Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] -[debug] [2025-04-06T10:39:45.829Z] > authorizing via signed-in user (pooh5821ingkanunt@gmail.com) -[info] i emulators: Starting emulators: hosting {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: hosting"}} -[debug] [2025-04-06T10:39:45.842Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1 -[debug] [2025-04-06T10:39:45.842Z] [hosting] Hosting Emulator only supports listening on one address (127.0.0.1). Not listening on ::1 -[debug] [2025-04-06T10:39:45.842Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"hosting":[{"address":"127.0.0.1","family":"IPv4","port":9999}]},"metadata":{"message":"assigned listening specs for emulators"}} -[debug] [2025-04-06T10:39:45.847Z] [hub] writing locator at C:\Users\Pooh5821\AppData\Local\Temp\hub-githubactionpractice-f87c3.json -[debug] [2025-04-06T10:39:45.862Z] Checked if tokens are valid: true, expires at: 1743938811343 -[debug] [2025-04-06T10:39:45.862Z] Checked if tokens are valid: true, expires at: 1743938811343 -[debug] [2025-04-06T10:39:45.863Z] >>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/githubactionpractice-f87c3/sites -[debug] [2025-04-06T10:39:46.919Z] <<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/githubactionpractice-f87c3/sites 200 -[debug] [2025-04-06T10:39:46.919Z] <<< [apiv2][body] GET https://firebasehosting.googleapis.com/v1beta1/projects/githubactionpractice-f87c3/sites {"sites":[{"name":"projects/githubactionpractice-f87c3/sites/githubactionpractice-f87c3","defaultUrl":"https://githubactionpractice-f87c3.web.app","type":"DEFAULT_SITE"}]} -[debug] [2025-04-06T10:39:46.919Z] Checked if tokens are valid: true, expires at: 1743938811343 -[debug] [2025-04-06T10:39:46.919Z] Checked if tokens are valid: true, expires at: 1743938811343 -[debug] [2025-04-06T10:39:46.919Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/githubactionpractice-f87c3/webApps/-/config [none] -[debug] [2025-04-06T10:39:47.857Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/githubactionpractice-f87c3/webApps/-/config 200 -[debug] [2025-04-06T10:39:47.858Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/githubactionpractice-f87c3/webApps/-/config {"projectId":"githubactionpractice-f87c3","storageBucket":"githubactionpractice-f87c3.firebasestorage.app","apiKey":"AIzaSyCuQiBdngHv9hdchembY-ZmXvEzCzPaPS8","authDomain":"githubactionpractice-f87c3.firebaseapp.com","messagingSenderId":"315115796797"} -[debug] [2025-04-06T10:39:47.869Z] Checked if tokens are valid: true, expires at: 1743938811343 -[debug] [2025-04-06T10:39:47.870Z] Checked if tokens are valid: true, expires at: 1743938811343 -[debug] [2025-04-06T10:39:47.870Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/githubactionpractice-f87c3 [none] -[debug] [2025-04-06T10:39:48.281Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/githubactionpractice-f87c3 200 -[debug] [2025-04-06T10:39:48.282Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/githubactionpractice-f87c3 {"projectId":"githubactionpractice-f87c3","projectNumber":"315115796797","displayName":"GitHubActionPractice","name":"projects/githubactionpractice-f87c3","resources":{"hostingSite":"githubactionpractice-f87c3"},"state":"ACTIVE","etag":"1_0a4ac934-b55a-461d-bdb0-e4977f340b2e"} -[info] i hosting[githubactionpractice-f87c3]: Serving hosting files from: public {"metadata":{"emulator":{"name":"hosting"},"message":"Serving hosting files from: \u001b[1mpublic\u001b[22m"}} -[info] + hosting[githubactionpractice-f87c3]: Local server: http://127.0.0.1:9999 {"metadata":{"emulator":{"name":"hosting"},"message":"Local server: \u001b[4m\u001b[1mhttp://127.0.0.1:9999\u001b[22m\u001b[24m"}} -[warn] ! emulators: The Emulator UI is not starting, either because none of the running emulators have a UI component or the Emulator UI cannot determine the Project ID. Pass the --project flag to specify a project. {"metadata":{"emulator":{"name":"hub"},"message":"The Emulator UI is not starting, either because none of the running emulators have a UI component or the Emulator UI cannot determine the Project ID. Pass the --project flag to specify a project."}} -[debug] [2025-04-06T10:39:48.306Z] Could not find VSCode notification endpoint: FetchError: request to http://localhost:40001/vscode/notify failed, reason: . If you are not running the Firebase Data Connect VSCode extension, this is expected and not an issue. -[info] -┌─────────────────────────────────────────────────────────────┐ -│ ✔ All emulators ready! It is now safe to connect your app. │ -└─────────────────────────────────────────────────────────────┘ - -┌──────────┬────────────────┐ -│ Emulator │ Host:Port │ -├──────────┼────────────────┤ -│ Hosting │ 127.0.0.1:9999 │ -└──────────┴────────────────┘ - Emulator Hub host: 127.0.0.1 port: 4400 - Other reserved ports: 4500 - -Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files. -