|
1 | 1 | /* eslint-disable no-use-before-define */ |
2 | 2 | /* eslint-disable no-console */ |
3 | | -import process from "node:process" |
| 3 | +// import process from "node:process" |
4 | 4 |
|
5 | | -import boxen from "boxen" |
6 | | -import { gray, dodgerblue } from "../config/colors.js" |
| 5 | +// const boxenOptions = { |
| 6 | +// borderColor: "blue", |
| 7 | +// margin: 1, |
| 8 | +// padding: 1, |
| 9 | +// } |
7 | 10 |
|
8 | | -const boxenOptions = { |
9 | | - borderColor: "blue", |
10 | | - margin: 1, |
11 | | - padding: 1, |
12 | | -} |
13 | | - |
14 | | -// Promotion starts on August 22, 2024 |
15 | | -const startAt = new Date("2024-08-22T00:00:00.000Z") |
16 | | -// By October 22, 2024, the promotion will be displayed to 100% of users |
17 | | -const endAt = new Date("2024-10-22T00:00:00.000Z") |
18 | | -const nDays = diffDays(startAt, endAt) |
| 11 | +// // Promotion starts on August 22, 2024 |
| 12 | +// const startAt = new Date("2024-08-22T00:00:00.000Z") |
| 13 | +// // By October 22, 2024, the promotion will be displayed to 100% of users |
| 14 | +// const endAt = new Date("2024-10-22T00:00:00.000Z") |
| 15 | +// const nDays = diffDays(startAt, endAt) |
19 | 16 |
|
20 | 17 | function logSponsor() { |
21 | | - if (!shouldDisplaySponsor()) { |
22 | | - console.log() |
23 | | - |
24 | | - return |
25 | | - } |
26 | | - |
27 | | - console.log( |
28 | | - boxen( |
29 | | - `Sponsored by ${dodgerblue("Arccode, the RPG for developers")}\nhttps://arccode.dev?ref=so\n${gray.dim( |
30 | | - "Disable with --noSponsor", |
31 | | - )}`, |
32 | | - boxenOptions, |
33 | | - ), |
34 | | - ) |
| 18 | + // if (!shouldDisplaySponsor()) { |
| 19 | + // console.log() |
| 20 | + // return |
| 21 | + // } |
| 22 | + // console.log( |
| 23 | + // boxen( |
| 24 | + // `Sponsored by ${dodgerblue("Arccode, the RPG for developers")}\nhttps://arccode.dev?ref=so\n${gray.dim( |
| 25 | + // "Disable with --noSponsor", |
| 26 | + // )}`, |
| 27 | + // boxenOptions, |
| 28 | + // ), |
| 29 | + // ) |
35 | 30 | } |
36 | 31 |
|
37 | 32 | // Display the message progressively over time to 100% of users |
38 | | -function shouldDisplaySponsor() { |
39 | | - const ratio = diffDays(startAt, new Date()) / nDays |
| 33 | +// function shouldDisplaySponsor() { |
| 34 | +// const ratio = diffDays(startAt, new Date()) / nDays |
40 | 35 |
|
41 | | - if (ratio >= 1) return true |
| 36 | +// if (ratio >= 1) return true |
42 | 37 |
|
43 | | - try { |
44 | | - const nonce = Number( |
45 | | - encodeStringToNumber(process.cwd()).toString().padStart(2, "0").slice(-2), |
46 | | - ) |
| 38 | +// try { |
| 39 | +// const nonce = Number( |
| 40 | +// encodeStringToNumber(process.cwd()).toString().padStart(2, "0").slice(-2), |
| 41 | +// ) |
47 | 42 |
|
48 | | - return nonce <= ratio * 100 |
49 | | - } catch { |
50 | | - // |
51 | | - } |
| 43 | +// return nonce <= ratio * 100 |
| 44 | +// } catch { |
| 45 | +// // |
| 46 | +// } |
52 | 47 |
|
53 | | - return false |
54 | | -} |
| 48 | +// return false |
| 49 | +// } |
55 | 50 |
|
56 | | -function encodeStringToNumber(string) { |
57 | | - let sum = 0 |
| 51 | +// function encodeStringToNumber(string) { |
| 52 | +// let sum = 0 |
58 | 53 |
|
59 | | - for (let i = 0; i < string.length; i += 1) { |
60 | | - sum += Number(string.codePointAt(i).toString(10)) |
61 | | - } |
| 54 | +// for (let i = 0; i < string.length; i += 1) { |
| 55 | +// sum += Number(string.codePointAt(i).toString(10)) |
| 56 | +// } |
62 | 57 |
|
63 | | - return sum |
64 | | -} |
| 58 | +// return sum |
| 59 | +// } |
| 60 | + |
| 61 | +// function diffDays(a, b) { |
| 62 | +// return Math.round((b - a) / (1000 * 60 * 60 * 24)) |
| 63 | +// } |
65 | 64 |
|
66 | | -function diffDays(a, b) { |
67 | | - return Math.round((b - a) / (1000 * 60 * 60 * 24)) |
68 | | -} |
69 | 65 | export default logSponsor |
0 commit comments