diff --git a/desktop/src/constants.ts b/client/src/constants.ts similarity index 100% rename from desktop/src/constants.ts rename to client/src/constants.ts diff --git a/client/src/index.ts b/client/src/index.ts index e69de29b..c94f80f8 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -0,0 +1 @@ +export * from './constants'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e3106ab6..c5dab748 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -151,6 +151,31 @@ importers: specifier: ^4.3.2 version: 4.3.2(typescript@5.4.5)(vite@5.2.11(@types/node@20.12.11)(sass@1.77.1)) + scripts: + dependencies: + '@flowr/utils': + specifier: ^3.2.1 + version: 3.2.1 + '@iarna/toml': + specifier: ^2.2.5 + version: 2.2.5 + execa: + specifier: ^9.0.2 + version: 9.0.2 + semver: + specifier: ^7.6.2 + version: 7.6.2 + undici: + specifier: ^6.16.1 + version: 6.16.1 + devDependencies: + '@types/iarna__toml': + specifier: ^2.0.5 + version: 2.0.5 + '@types/semver': + specifier: ^7.5.8 + version: 7.5.8 + packages: '@adobe/css-tools@4.3.3': @@ -609,6 +634,9 @@ packages: '@humanwhocodes/object-schema@2.0.3': resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} + '@iarna/toml@2.2.5': + resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} + '@iconify-json/logos@1.1.42': resolution: {integrity: sha512-/f+frtPm3m3Z30oy8Pk+QqRDkbmAiIaWGPl5CmsCXm15MVfvw9a/V/gD7WzdyuSGAZcFuQaqbHXj92y/n+2ifg==} @@ -763,9 +791,16 @@ packages: peerDependencies: '@tauri-apps/api': ^1.2.0 + '@sec-ant/readable-stream@0.4.1': + resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==} + '@sinclair/typebox@0.27.8': resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} + '@sindresorhus/merge-streams@4.0.0': + resolution: {integrity: sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==} + engines: {node: '>=18'} + '@solid-primitives/deep@0.2.8': resolution: {integrity: sha512-r+enqrL2oiDkJt7lYUYMVvKzcqVDAd4G/1OkLnXEibk5nIA635qNIuOxIAaCCP3GDAHKznaW3yc/vMG68lo8bQ==} peerDependencies: @@ -984,6 +1019,9 @@ packages: '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} + '@types/iarna__toml@2.0.5': + resolution: {integrity: sha512-I55y+SxI0ayM4MBU6yfGJGmi4wRll6wtSeKiFYAZj+Z5Q1DVbMgBSVDYY+xQZbjIlLs/pN4fidnvR8faDrmxPg==} + '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} @@ -1822,6 +1860,10 @@ packages: resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} engines: {node: '>=16.17'} + execa@9.0.2: + resolution: {integrity: sha512-oO281GF7ksH/Ogv1xyDf1prvFta/6/XkGKxRUvA3IB2MU1rCJGlFs86HRZhdooow1ISkR0Np0rOxUCIJVw36Rg==} + engines: {node: '>=18'} + fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -1845,6 +1887,10 @@ packages: fflate@0.8.2: resolution: {integrity: sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==} + figures@6.1.0: + resolution: {integrity: sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==} + engines: {node: '>=18'} + file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -1916,6 +1962,10 @@ packages: resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} engines: {node: '>=16'} + get-stream@9.0.1: + resolution: {integrity: sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==} + engines: {node: '>=18'} + get-tsconfig@4.7.5: resolution: {integrity: sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==} @@ -2030,6 +2080,10 @@ packages: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} + human-signals@7.0.0: + resolution: {integrity: sha512-74kytxOUSvNbjrT9KisAbaTZ/eJwD/LrbM/kh5j0IhPuJzwuA19dWvniFGwBzN9rVjg+O/e+F310PjObDXS+9Q==} + engines: {node: '>=18.18.0'} + iconv-lite@0.6.3: resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==} engines: {node: '>=0.10.0'} @@ -2143,6 +2197,10 @@ packages: resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} engines: {node: '>=8'} + is-plain-obj@4.1.0: + resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==} + engines: {node: '>=12'} + is-potential-custom-element-name@1.0.1: resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==} @@ -2166,6 +2224,10 @@ packages: resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + is-stream@4.0.1: + resolution: {integrity: sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==} + engines: {node: '>=18'} + is-string@1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} engines: {node: '>= 0.4'} @@ -2174,6 +2236,10 @@ packages: resolution: {integrity: sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==} engines: {node: '>= 0.4'} + is-unicode-supported@2.0.0: + resolution: {integrity: sha512-FRdAyx5lusK1iHG0TWpVtk9+1i+GjrzRffhDg4ovQ7mcidMQ6mj+MhKPmvh7Xwyv5gIS06ns49CA7Sqg7lC22Q==} + engines: {node: '>=18'} + is-weakmap@2.0.2: resolution: {integrity: sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==} engines: {node: '>= 0.4'} @@ -2301,10 +2367,6 @@ packages: lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} - lru-cache@6.0.0: - resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} - engines: {node: '>=10'} - luxon@3.4.4: resolution: {integrity: sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA==} engines: {node: '>=12'} @@ -2541,6 +2603,10 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} + parse-ms@4.0.0: + resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==} + engines: {node: '>=18'} + parse5@7.1.2: resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==} @@ -2626,6 +2692,10 @@ packages: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + pretty-ms@9.0.0: + resolution: {integrity: sha512-E9e9HJ9R9NasGOgPaPE8VMeiPKAyWR5jcFpNnwIejslIhWqdqOrb2wShBsncMPUb+BcCd2OPYfh7p2W6oemTng==} + engines: {node: '>=18'} + prompts@2.4.2: resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} engines: {node: '>= 6'} @@ -2734,10 +2804,7 @@ packages: semver@6.3.1: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} - - semver@7.6.0: - resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} - engines: {node: '>=10'} + hasBin: true semver@7.6.2: resolution: {integrity: sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==} @@ -2858,6 +2925,10 @@ packages: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} + strip-final-newline@4.0.0: + resolution: {integrity: sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw==} + engines: {node: '>=18'} + strip-indent@3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -3016,6 +3087,10 @@ packages: undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + undici@6.16.1: + resolution: {integrity: sha512-NeNiTT7ixpeiL1qOIU/xTVpHpVP0svmI6PwoCKaMGaI5AsHOaRdwqU/f7Fi9eyU4u03nd5U/BC8wmRMnS9nqoA==} + engines: {node: '>=18.17'} + unicorn-magic@0.1.0: resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} engines: {node: '>=18'} @@ -3253,6 +3328,10 @@ packages: resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} engines: {node: '>=12.20'} + yoctocolors@2.0.0: + resolution: {integrity: sha512-esbDnt0Z1zI1KgvOZU90hJbL6BkoUbrP9yy7ArNZ6TmxBxydMJTYMf9FZjmwwcA8ZgEQzriQ3hwZ0NYXhlFo8Q==} + engines: {node: '>=18'} + zod@3.23.8: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} @@ -3762,6 +3841,8 @@ snapshots: '@humanwhocodes/object-schema@2.0.3': {} + '@iarna/toml@2.2.5': {} + '@iconify-json/logos@1.1.42': dependencies: '@iconify/types': 2.0.0 @@ -3893,8 +3974,12 @@ snapshots: '@rspc/client': 0.2.0 '@tauri-apps/api': 2.0.0-beta.8 + '@sec-ant/readable-stream@0.4.1': {} + '@sinclair/typebox@0.27.8': {} + '@sindresorhus/merge-streams@4.0.0': {} + '@solid-primitives/deep@0.2.8(solid-js@1.8.17)': dependencies: '@solid-primitives/memo': 1.3.8(solid-js@1.8.17) @@ -4103,6 +4188,10 @@ snapshots: '@types/estree@1.0.5': {} + '@types/iarna__toml@2.0.5': + dependencies: + '@types/node': 20.12.11 + '@types/json-schema@7.0.15': {} '@types/mdast@3.0.15': @@ -4188,7 +4277,7 @@ snapshots: globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.4 - semver: 7.6.0 + semver: 7.6.2 ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: typescript: 5.4.5 @@ -4219,7 +4308,7 @@ snapshots: '@typescript-eslint/types': 7.7.1 '@typescript-eslint/typescript-estree': 7.7.1(typescript@5.4.5) eslint: 8.57.0 - semver: 7.6.0 + semver: 7.6.2 transitivePeerDependencies: - supports-color - typescript @@ -4619,7 +4708,7 @@ snapshots: fast-glob: 3.3.2 js-yaml: 4.1.0 prompts: 2.4.2 - semver: 7.6.0 + semver: 7.6.2 c12@1.10.0: dependencies: @@ -5236,6 +5325,21 @@ snapshots: signal-exit: 4.1.0 strip-final-newline: 3.0.0 + execa@9.0.2: + dependencies: + '@sindresorhus/merge-streams': 4.0.0 + cross-spawn: 7.0.3 + figures: 6.1.0 + get-stream: 9.0.1 + human-signals: 7.0.0 + is-plain-obj: 4.1.0 + is-stream: 4.0.1 + npm-run-path: 5.3.0 + pretty-ms: 9.0.0 + signal-exit: 4.1.0 + strip-final-newline: 4.0.0 + yoctocolors: 2.0.0 + fast-deep-equal@3.1.3: {} fast-equals@5.0.1: {} @@ -5258,6 +5362,10 @@ snapshots: fflate@0.8.2: {} + figures@6.1.0: + dependencies: + is-unicode-supported: 2.0.0 + file-entry-cache@6.0.1: dependencies: flat-cache: 3.2.0 @@ -5329,6 +5437,11 @@ snapshots: get-stream@8.0.1: {} + get-stream@9.0.1: + dependencies: + '@sec-ant/readable-stream': 0.4.1 + is-stream: 4.0.1 + get-tsconfig@4.7.5: dependencies: resolve-pkg-maps: 1.0.0 @@ -5444,6 +5557,8 @@ snapshots: human-signals@5.0.0: {} + human-signals@7.0.0: {} + iconv-lite@0.6.3: dependencies: safer-buffer: 2.1.2 @@ -5546,6 +5661,8 @@ snapshots: is-path-inside@3.0.3: {} + is-plain-obj@4.1.0: {} + is-potential-custom-element-name@1.0.1: {} is-regex@1.1.4: @@ -5563,6 +5680,8 @@ snapshots: is-stream@3.0.0: {} + is-stream@4.0.1: {} + is-string@1.0.7: dependencies: has-tostringtag: 1.0.2 @@ -5571,6 +5690,8 @@ snapshots: dependencies: has-symbols: 1.0.3 + is-unicode-supported@2.0.0: {} + is-weakmap@2.0.2: {} is-weakset@2.0.3: @@ -5695,10 +5816,6 @@ snapshots: dependencies: yallist: 3.1.1 - lru-cache@6.0.0: - dependencies: - yallist: 4.0.0 - luxon@3.4.4: {} lz-string@1.5.0: {} @@ -5941,6 +6058,8 @@ snapshots: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 + parse-ms@4.0.0: {} + parse5@7.1.2: dependencies: entities: 4.5.0 @@ -6008,6 +6127,10 @@ snapshots: ansi-styles: 5.2.0 react-is: 18.3.1 + pretty-ms@9.0.0: + dependencies: + parse-ms: 4.0.0 + prompts@2.4.2: dependencies: kleur: 3.0.3 @@ -6129,10 +6252,6 @@ snapshots: semver@6.3.1: {} - semver@7.6.0: - dependencies: - lru-cache: 6.0.0 - semver@7.6.2: {} serialize-error@11.0.3: @@ -6248,6 +6367,8 @@ snapshots: strip-final-newline@3.0.0: {} + strip-final-newline@4.0.0: {} + strip-indent@3.0.0: dependencies: min-indent: 1.0.1 @@ -6387,6 +6508,8 @@ snapshots: undici-types@5.26.5: {} + undici@6.16.1: {} + unicorn-magic@0.1.0: {} unist-util-stringify-position@2.0.3: @@ -6636,4 +6759,6 @@ snapshots: yocto-queue@1.0.0: {} + yoctocolors@2.0.0: {} + zod@3.23.8: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 52e65436..23d434a5 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,4 @@ packages: - desktop - client + - scripts diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 00000000..6ba3ff69 --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,30 @@ +{ + "name": "@onelauncher/scripts", + "type": "module", + "version": "1.0.0", + "private": true, + "description": "Scripts for developing OneLauncher", + "license": "GPL-3.0-only", + "repository": { + "type": "git", + "url": "git@github.com:polyfrost/onelauncher", + "directory": "client" + }, + "sideEffects": false, + "main": "./src/index.ts", + "types": "./src/index.ts", + "scripts": { + "tauri": "tsx tauri.ts" + }, + "dependencies": { + "@flowr/utils": "^3.2.1", + "@iarna/toml": "^2.2.5", + "execa": "^9.0.2", + "semver": "^7.6.2", + "undici": "^6.16.1" + }, + "devDependencies": { + "@types/iarna__toml": "^2.0.5", + "@types/semver": "^7.5.8" + } +} diff --git a/scripts/prepare.ts b/scripts/prepare.ts new file mode 100644 index 00000000..e69de29b diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 new file mode 100644 index 00000000..b375ce39 --- /dev/null +++ b/scripts/setup.ps1 @@ -0,0 +1,231 @@ +# Set default value of 0 for external command exit code +$LASTEXITCODE = 0 +# Enables strict mode, which causes PowerShell to treat uninitialized variables, undefined functions, and other common errors as terminating errors. +$ErrorActionPreference = if ($env:CI) { 'Stop' } else { 'Inquire' } +Set-StrictMode -Version Latest + +function Reset-Path { + $env:Path = [System.Environment]::ExpandEnvironmentVariables( + [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + + [IO.Path]::PathSeparator + + [System.Environment]::GetEnvironmentVariable('Path', 'User') + ) +} + +# Verify if environment is Windows 64-bit and if the user is an administrator +if ((-not [string]::IsNullOrEmpty($env:PROCESSOR_ARCHITEW6432)) -or ( + "$env:PROCESSOR_ARCHITECTURE" -eq 'ARM64' + ) -or ( + -not [System.Environment]::Is64BitOperatingSystem + # Powershell >= 6 is cross-platform, check if running on Windows + ) -or (($PSVersionTable.PSVersion.Major -ge 6) -and (-not $IsWindows)) +) { + $ErrorActionPreference = 'Continue' + Write-Host + if (Test-Path "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe" -PathType Leaf) { + throw 'You are using PowerShell (32-bit), please re-run in PowerShell (64-bit)' + } else { + throw 'This script is only supported on Windows 64-bit' + } + Exit 1 +} elseif ( + -not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +) { + # Start a new PowerShell process with administrator privileges and set the working directory to the directory where the script is located + $proc = Start-Process -PassThru -Wait -FilePath 'PowerShell.exe' -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Definition)`"" -WorkingDirectory "$PSScriptRoot" + # Reset path so the user doesn't have to restart the shell to use the tools installed by this script + Reset-Path + Exit $proc.ExitCode +} + +function Exit-WithError($err, $help = $null) { + if ($null -ne $help) { + Write-Host + Write-Host $help -ForegroundColor DarkRed + } + throw $err + Exit 1 +} + +function Add-DirectoryToPath($directory) { + Reset-Path + if ($env:Path.Split([IO.Path]::PathSeparator) -notcontains $directory) { + [System.Environment]::SetEnvironmentVariable( + 'Path', + [System.Environment]::GetEnvironmentVariable('Path', 'User') + [IO.Path]::PathSeparator + $directory, + 'User' + ) + + if ($env:CI) { + # If running in CI, we need to use GITHUB_PATH instead of the normal PATH env variables + Add-Content $env:GITHUB_PATH "$directory`n" + } + } + Reset-Path +} + +# Reset PATH to ensure the script doesn't have stale Path entries +Reset-Path + +# Get project dir (get grandparent dir from script location: \scripts\setup.ps1) +$projectRoot = Split-Path -Path $PSScriptRoot -Parent +$packageJson = Get-Content -Raw -Path "$projectRoot\package.json" | ConvertFrom-Json + +# Valid winget exit status +$wingetValidExit = 0, -1978335189, -1978335153, -1978335135 + +Write-Host 'OneLauncher Development Environment Setup' -ForegroundColor Magenta +Write-Host @" + +To set up your machine for OneLauncher development, this script will do the following: +1) Install Windows C++ build tools +2) Install Edge Webview 2 +3) Install Rust and Cargo +4) Install Rust tools +5) Install Node.js, npm and pnpm +"@ + +# Install System dependencies (GitHub Actions already has all of those installed) +if (-not $env:CI) { + if (-not (Get-Command winget -ea 0)) { + Exit-WithError 'winget not available' @' +Follow the instructions here to install winget: +https://learn.microsoft.com/windows/package-manager/winget/ +'@ + } + + # Check system winget version is greater or equal to v1.4.10052 + $wingetVersion = [Version]((winget --version) -replace '.*?(\d+)\.(\d+)\.(\d+).*', '$1.$2.$3') + $requiredVersion = [Version]'1.4.10052' + if ($wingetVersion.CompareTo($requiredVersion) -lt 0) { + $errorMessage = "You need to update your winget to version $requiredVersion or higher." + Exit-WithError $errorMessage + } + + # Check connectivity to GitHub + $ProgressPreference = 'SilentlyContinue' + if (-not ((Test-NetConnection -ComputerName 'github.com' -Port 80).TcpTestSucceeded)) { + Exit-WithError "Can't connect to github, check your internet connection and run this script again" + } + $ProgressPreference = 'Continue' + + Write-Host + Read-Host 'Press Enter to continue' + + # TODO: Force update Visual Studio build tools + Write-Host + Write-Host 'Installing Visual Studio Build Tools...' -ForegroundColor Yellow + Write-Host 'This will take some time as it involves downloading several gigabytes of data....' -ForegroundColor Cyan + winget install -e --accept-source-agreements --force --disable-interactivity --id Microsoft.VisualStudio.2022.BuildTools ` + --override 'updateall --quiet --wait' + # Force install because BuildTools is itself a package manager, so let it decide if something needs to be installed or not + winget install -e --accept-source-agreements --force --disable-interactivity --id Microsoft.VisualStudio.2022.BuildTools ` + --override '--wait --quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended' + if (-not ($wingetValidExit -contains $LASTEXITCODE)) { + Exit-WithError 'Failed to install Visual Studio Build Tools' + } else { + $LASTEXITCODE = 0 + } + + Write-Host + Write-Host 'Installing Edge Webview 2...' -ForegroundColor Yellow + # This is normally already available, but on some early Windows 10 versions it isn't + winget install -e --accept-source-agreements --disable-interactivity --id Microsoft.EdgeWebView2Runtime + if (-not ($wingetValidExit -contains $LASTEXITCODE)) { + Exit-WithError 'Failed to install Edge Webview 2' + } else { + $LASTEXITCODE = 0 + } + + Write-Host + Write-Host 'Installing Rust and Cargo...' -ForegroundColor Yellow + winget install -e --accept-source-agreements --disable-interactivity --id Rustlang.Rustup + if (-not ($wingetValidExit -contains $LASTEXITCODE)) { + Exit-WithError 'Failed to install Rust and Cargo' + } else { + $LASTEXITCODE = 0 + } + + Write-Host + Write-Host 'Installing Nasm...' -ForegroundColor Yellow + winget install -e --accept-source-agreements --disable-interactivity --id NASM.NASM + if (-not ($wingetValidExit -contains $LASTEXITCODE)) { + Exit-WithError 'Failed to install Nasm' + } else { + $LASTEXITCODE = 0 + } + + Write-Host + Write-Host 'Installing NodeJS...' -ForegroundColor Yellow + # Check if Node.JS is already installed and if it's compatible with the project + $currentNode = Get-Command node -ea 0 + $currentNodeVersion = if (-not $currentNode) { $null } elseif ($currentNode.Version) { $currentNode.Version } elseif ((node --version) -match '(?sm)(\d+(\.\d+)*)') { [Version]$matches[1] } else { $null } + $enginesNodeVersion = if ($packageJson.engines.node -match '(?sm)(\d+(\.\d+)*)') { [Version]$matches[1] } else { $null } + if ($currentNodeVersion -and $enginesNodeVersion -and $currentNodeVersion.CompareTo($enginesNodeVersion) -lt 0) { + Exit-WithError "Current Node.JS version: $currentNodeVersion (required: $enginesNodeVersion)" ` + 'Uninstall the current version of Node.JS and run this script again' + } + # Install Node.JS + winget install -e --accept-source-agreements --disable-interactivity --id OpenJS.NodeJS + if (-not ($wingetValidExit -contains $LASTEXITCODE)) { + Exit-WithError 'Failed to install NodeJS' + } else { + $LASTEXITCODE = 0 + } + # Add NodeJS to the PATH + Add-DirectoryToPath "$env:SystemDrive\Program Files\nodejs" + + # Reset Path to ensure that executable installed above are available to rest of the script + Reset-Path + + Write-Host + Write-Host 'Installing Rust MSVC Toolchain...' -ForegroundColor Yellow + rustup toolchain install stable-msvc + if ($LASTEXITCODE -ne 0) { + Exit-WithError 'Failed to install Rust MSVC Toolchain' + } + + Write-Host + Write-Host 'Installing Rust tools...' -ForegroundColor Yellow + cargo install cargo-watch + if ($LASTEXITCODE -ne 0) { + Exit-WithError 'Failed to install Rust tools' + } + + Write-Host + Write-Host 'Installing for pnpm...' -ForegroundColor Yellow + # Check if pnpm is already installed and if it's compatible with the project + $currentPnpmVersion = if (-not (Get-Command pnpm -ea 0)) { $null } elseif ((pnpm --version) -match '(?sm)(\d+(\.\d+)*)') { [Version]$matches[1] } else { $null } + $enginesPnpmVersion = if ($packageJson.engines.pnpm -match '(?sm)(\d+(\.\d+)*)') { [Version]$matches[1] } else { $null } + + if (-not $currentPnpmVersion) { + # Remove possible remaining envvars from old pnpm installation + [System.Environment]::SetEnvironmentVariable('PNPM_HOME', $null, [System.EnvironmentVariableTarget]::Machine) + [System.Environment]::SetEnvironmentVariable('PNPM_HOME', $null, [System.EnvironmentVariableTarget]::User) + + # Install pnpm + npm install -g "pnpm@latest-$($enginesPnpmVersion.Major)" + if ($LASTEXITCODE -ne 0) { + Exit-WithError 'Failed to install pnpm' + } + + # Add NPM global modules to the PATH + if (Test-Path "$env:APPDATA\npm" -PathType Container) { + Add-DirectoryToPath "$env:APPDATA\npm" + } + } elseif ($currentPnpmVersion -and $enginesPnpmVersion -and $currentPnpmVersion.CompareTo($enginesPnpmVersion) -lt 0) { + Exit-WithError "Current pnpm version: $currentPnpmVersion (required: $enginesPnpmVersion)" ` + 'Uninstall the current version of pnpm and run this script again' + } +} + +if ($LASTEXITCODE -ne 0) { + Exit-WithError "Something went wrong, exit code: $LASTEXITCODE" +} + +if (-not $env:CI) { + Write-Host + Write-Host 'Your machine has been setup for OneLauncher development!' -ForegroundColor Green + Write-Host + Read-Host 'Press Enter to continue' +} diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 00000000..e880ce4e --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,165 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [ "${CI:-}" = "true" ]; then + set -x +fi + +err() { + for _line in "$@"; do + echo "$_line" >&2 + done + exit 1 +} + +has() { + for prog in "$@"; do + if ! command -v "$prog" 1>/dev/null 2>&1; then + return 1 + fi + done +} + +sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + env sudo "$@" + fi +} + +script_failure() { + if [ -n "${1:-}" ]; then + _line="on line $1" + else + _line="(unknown)" + fi + err "An error occurred $_line." "Setup failed." +} + +trap 'script_failure ${LINENO:-}' ERR + +case "${OSTYPE:-}" in + 'msys' | 'mingw' | 'cygwin') + err 'Bash for Windows is not supported, please use Powershell or CMD' + ;; +esac + +if [ "${CI:-}" != "true" ]; then + echo 'OneLauncher Development Environment Setup' + echo 'To set up your machine for OneLauncher development, this script will install some required dependencies with your system package manager' + echo + echo 'Press Enter to continue' + read -r + + if ! has pnpm; then + err 'pnpm was not found.' \ + "Ensure the 'pnpm' command is in your \$PATH." \ + 'You must use pnpm for this project; yarn and npm are not allowed.' \ + 'https://pnpm.io/installation' + fi + + if ! has rustc cargo; then + err 'Rust was not found.' \ + "Ensure the 'rustc' and 'cargo' binaries are in your \$PATH." \ + 'https://rustup.rs' + fi + + echo +fi + +# Install system deps +case "$(uname)" in + "Darwin") + if [ "$(uname -m)" = 'x86_64' ] && ! [ "${CI:-}" = "true" ]; then + brew install nasm + fi + ;; + "Linux") + # https://v2.tauri.app/start/prerequisites/ + if has apt-get; then + echo "Detected apt!" + echo "Installing dependencies with apt..." + + # Tauri dependencies + set -- build-essential curl wget file libssl-dev libgtk-3-dev librsvg2-dev \ + libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libxdo-dev libvips42 + + sudo apt-get -y update + sudo apt-get -y install "$@" + elif has pacman; then + echo "Detected pacman!" + echo "Installing dependencies with pacman..." + + # Tauri dependencies + set -- appmenu-gtk-module libappindicator-gtk3 base-devel curl wget file openssl gtk3 librsvg webkit2gtk-4.1 libayatana-appindicator xdotool libvips + + sudo pacman -Sy --needed "$@" + elif has dnf; then + echo "Detected dnf!" + echo "Installing dependencies with dnf..." + + # For Enterprise Linux, you also need "Development Tools" instead of "C Development Tools and Libraries" + if ! { sudo dnf group install "C Development Tools and Libraries" || sudo dnf group install "Development Tools"; }; then + err 'We were unable to install the "C Development Tools and Libraries"/"Development Tools" package.' \ + 'Please open an issue if you feel that this is incorrect.' + fi + + # Tauri dependencies + set -- openssl webkit2gtk4.1-devel openssl-devel curl wget file libappindicator-gtk3-devel librsvg2-devel libxdo-devel vips + + sudo dnf install "$@" + elif has apk; then + echo "Detected apk!" + echo "Installing dependencies with apk..." + echo "Alpine suport is experimental" >&2 + + # Tauri dependencies + set -- build-base curl wget file openssl-dev gtk+3.0-dev librsvg-dev \ + webkit2gtk-4.1-dev libayatana-indicator-dev xdotool vips + + sudo apk add "$@" + elif has emerge; then + echo "Detected emerge!" + echo "Installing dependencies with emerge..." + echo "Gentoo support is experiemntal" >&2 + + # Tauri Dependencies + set -- net-libs/webkit-gtk:4.1 dev-libs/libappindicator net-misc/curl net-misc/wget sys-apps/file + + sudo emerge --ask "$@" + elif has zypper; then + echo "Detected zypper!" + echo "Installing dependencies with zypper..." + echo "openSUSE support is experimental" >&2 + + set -- libopenssl-devel webkit2gtk3-devel curl wget file libappindicator3-1 librsvg-devel + + sudo zypper in "$@" + sudo zypper in -t pattern devel_basis + else + if has lsb_release; then + _distro="'$(lsb_release -s -d)' " + fi + err "Your Linux distro ${_distro:-}is not supported by this script." \ + 'We would welcome a PR or some help adding your OS to this script:' \ + 'https://github.com/polyfrost/onelauncher/issues' + fi + ;; + *) + err "Your OS ($(uname)) is not supported by this script." \ + 'We would welcome a PR or some help adding your OS to this script.' \ + 'https://github.com/polyfrost/onelauncher/issues' + ;; +esac + +if [ "${CI:-}" != "true" ]; then + echo "Installing Rust tools..." + + _tools="cargo-watch" + + echo "$_tools" | xargs cargo install +fi + +echo 'Your machine has been setup for OneLauncher development!' diff --git a/scripts/tauri.ts b/scripts/tauri.ts new file mode 100644 index 00000000..e69de29b diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 00000000..ad1983a6 --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.base.json", + "include": ["./**/*.ts"] +} diff --git a/scripts/utils/fetch.ts b/scripts/utils/fetch.ts new file mode 100644 index 00000000..d7989c86 --- /dev/null +++ b/scripts/utils/fetch.ts @@ -0,0 +1,6 @@ +import type { Agent } from 'undici'; + +const agentOptions: Agent.Options = { + allowH2: true, + connect: { timeout: CONNECT_TIMEOUT }, +}; diff --git a/scripts/utils/flock.ts b/scripts/utils/flock.ts new file mode 100644 index 00000000..e69de29b diff --git a/scripts/utils/patch.ts b/scripts/utils/patch.ts new file mode 100644 index 00000000..e69de29b diff --git a/scripts/utils/shared.ts b/scripts/utils/shared.ts new file mode 100644 index 00000000..e69de29b diff --git a/scripts/utils/triple.ts b/scripts/utils/triple.ts new file mode 100644 index 00000000..5c3dedc3 --- /dev/null +++ b/scripts/utils/triple.ts @@ -0,0 +1,66 @@ +import { env } from 'node:process'; +import * as os from 'node:os'; +import { execaCommand } from 'execa'; + +const state: { __debug: boolean; libc: 'musl' | 'glibc' } = { + __debug: env.NODE_ENV === 'debug', + libc: 'glibc', +}; + +if (os.type() === 'Linux') { + try { + const lldResult = await execaCommand('ldd /bin/ls'); + if (lldResult.stdout.includes('msl')) + state.libc = 'musl'; + } + catch (error) { + if (state.__debug) { + console.warn('failed to check libs type'); + console.error(error); + } + } +} + +const OS_TYPE: Record = { + darwin: 'Darwin', + windows: 'Windows_NT', + linux: 'Linux', +}; + +type TripleID = ['Darwin' | 'Windows_NT', 'x86_64' | 'aarch64'] | ['Linux', 'x86_64' | 'aarch64', 'musl' | 'glibc']; + +export function getTriple(): TripleID { + const tripleState: { + _libc: typeof state.libc; + _os: string; + _arch: string; + } = { + _libc: state.libc, + _os: '', + _arch: '', + }; + + if (env.TARGET_TRIPLE) { + const target = env.TARGET_TRIPLE.split('-'); + tripleState._os = OS_TYPE[target[2] ?? ''] as string; + tripleState._arch = target[0] as string; + if (tripleState._os === 'Linux') + tripleState._libc = target[3]?.includes('musl') ? 'musl' : 'glibc'; + } + else { + tripleState._os = os.type(); + tripleState._arch = os.machine(); + if (tripleState._arch === 'arm64') + tripleState._arch = 'aarch64'; + } + + if (tripleState._arch !== 'x86_64' && tripleState._arch !== 'aarch64') + throw new Error(`Unsuported architecture`); + + if (tripleState._os === 'Linux') + return [tripleState._os, tripleState._arch, tripleState._libc]; + else if (tripleState._os !== 'Darwin' && tripleState._os !== 'Windows_NT') + throw new Error(`Unsuported OS`); + + return [tripleState._os, tripleState._arch]; +} diff --git a/scripts/utils/which.ts b/scripts/utils/which.ts new file mode 100644 index 00000000..e69de29b