diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 15900c684..c6f378f6b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ There are many ways to contribute to the Lit project, and we have many different We have a [Code of Conduct](https://github.com/lit/lit/blob/main/CODE_OF_CONDUCT.md), please follow it in all interactions with project maintainers and fellow users. ## Set up - +Starting on mac or linux distros works out of the box, windows requires some extra [setup](WINDOWS.md) ```bash git clone https://github.com/lit/lit.dev.git cd lit.dev diff --git a/README.md b/README.md index eadc75762..07658abac 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ npm ci ``` ### Develop site content - +Starting on mac or linux distros works out of the box, windows requires some extra [setup](WINDOWS.md) ```sh npm run dev ``` diff --git a/WINDOWS.md b/WINDOWS.md new file mode 100644 index 000000000..8f19b774c --- /dev/null +++ b/WINDOWS.md @@ -0,0 +1,32 @@ + +# Lit.dev Windows Guide +## Setup + +### Patch +Windows comes without [patch][patch-manual] but is included in allot of tools and probably already on your system.
+If you already have patch available then make sure you have it added to your PATH (Environment Variables)
+ +#### Getting patch +The simpliest way to get patch on your system is to install one of the package-managers,terminals etc from below +- [cygwin][install-cygwin] +- [msys2][install-msys2] +- [cmder][install-cmder] +- [git][install-git] + +### Symlinks +Symlinks require admin access so will fail and return a EPERM error.
+There are two options +- [setting security policy](https://superuser.com/questions/104845/permission-to-make-symbolic-links-in-windows-7) +- [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) +- [run your terminal as admin](https://www.thewindowsclub.com/how-to-run-command-prompt-as-an-administrator) + +***Notes***
+option two comes with security risks, read trough carefully and if you don't fully understand use option one!
+option three only applies when your an admin and option one can't be used unless you remove the account from the admin group. + + +[install-cygwin]: https://cygwin.com/install.html +[install-msys2]: https://www.msys2.org/ +[install-cmder]: https://cmder.app/ +[install-git]: https://git-scm.com/download/win +[patch-manual]: https://www.unix.com/man-page/minix/1/patch/ \ No newline at end of file diff --git a/packages/lit-dev-content/package.json b/packages/lit-dev-content/package.json index e5c581fad..f835be21c 100644 --- a/packages/lit-dev-content/package.json +++ b/packages/lit-dev-content/package.json @@ -104,7 +104,7 @@ ] }, "fonts:manrope": { - "command": "rm -rf temp && mkdir -p site/fonts/manrope && git clone https://github.com/sharanda/manrope.git temp/manrope && cd temp/manrope && git checkout 9ffbc349f4659065b62f780fe6e9d5a93518bd95 && cp fonts/web/*.woff2 ../../site/fonts/manrope/ && cd ../.. && rm -rf temp", + "command": "node scripts/fonts.js", "files": [], "output": [ "site/fonts/manrope" diff --git a/packages/lit-dev-content/rollup.config.js b/packages/lit-dev-content/rollup.config.js index b6eb2ad84..d2a4f2136 100644 --- a/packages/lit-dev-content/rollup.config.js +++ b/packages/lit-dev-content/rollup.config.js @@ -8,6 +8,11 @@ import resolve from '@rollup/plugin-node-resolve'; import summary from 'rollup-plugin-summary'; import {terser} from 'rollup-plugin-terser'; import minifyHTML from 'rollup-plugin-minify-html-literals'; +import { dirname, sep} from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); const terserOptions = { warnings: true, @@ -57,7 +62,7 @@ export default [ format: 'esm', // Preserve directory structure for entrypoints. entryFileNames: ({facadeModuleId}) => - facadeModuleId.replace(`${__dirname}/lib/`, ''), + facadeModuleId.replace(`${__dirname}${sep}lib${sep}`, ''), manualChunks: (id) => { // Create some more logical shared chunks. In particular, people will // probably be looking for lit.js in devtools! @@ -141,7 +146,7 @@ export default [ format: 'esm', // Preserve directory structure for entrypoints. entryFileNames: ({facadeModuleId}) => - facadeModuleId.replace(`${__dirname}/lib/`, ''), + facadeModuleId.replace(`${__dirname}${sep}lib${sep}`, ''), }, plugins: [ resolve(), diff --git a/packages/lit-dev-content/scripts/fonts.js b/packages/lit-dev-content/scripts/fonts.js new file mode 100644 index 000000000..b079aab55 --- /dev/null +++ b/packages/lit-dev-content/scripts/fonts.js @@ -0,0 +1,27 @@ +const rimraf = require('rimraf') +const {mkdirSync, copyFileSync} = require('fs') +const {execFileSync, execSync} = require('child_process') +const glob = require('globby') +const {parse} = require('path') + + + +rimraf.sync('temp') + +try { + mkdirSync('site/fonts/manrope') +} catch { + // already exists +} + +// clone the fonts repo +// TODO: check if the folder already exists +execFileSync('git', ['clone', 'https://github.com/sharanda/manrope.git', 'temp/manrope']) +execSync('cd temp/manrope && git checkout 9ffbc349f4659065b62f780fe6e9d5a93518bd95') +// get the desired font files to copy +const files = glob.sync('temp/manrope/fonts/web/*.woff2') +// copy the files to site/fonts/manrope +for (const file of files) { + const parsed = parse(file) + copyFileSync(file, `site/fonts/manrope/${parsed.name}${parsed.ext}`) +} \ No newline at end of file diff --git a/packages/lit-dev-tools-cjs/src/api-docs/generate.ts b/packages/lit-dev-tools-cjs/src/api-docs/generate.ts index 6405edd21..abc75dfc9 100644 --- a/packages/lit-dev-tools-cjs/src/api-docs/generate.ts +++ b/packages/lit-dev-tools-cjs/src/api-docs/generate.ts @@ -15,6 +15,8 @@ import {lit3Config} from './configs/lit-3.js'; import type {ApiDocsConfig} from './types.js'; +const isWindows = /^win/.test(process.platform) + const execFileAsync = promisify(execFile); // Only generate documentation for most recent Lit versions. @@ -61,9 +63,10 @@ const INSTALLED_FILE = 'INSTALLED'; */ const setup = async (config: ApiDocsConfig) => { console.log(`running npm ci in ${config.gitDir}`); - await execFileAsync('npm', ['ci'], {cwd: config.gitDir}); - for (const {cmd, args} of config.extraSetupCommands ?? []) { + await execFileAsync(isWindows ? 'npm.cmd' : 'npm', ['ci'], {cwd: config.gitDir}); + for (let {cmd, args} of config.extraSetupCommands ?? []) { console.log(`running ${cmd} ${args.join(' ')} in ${config.gitDir}`); + if (cmd === 'npm' && isWindows) cmd = 'npm.cmd' await execFileAsync(cmd, args, {cwd: config.gitDir}); } await fs.writeFile(pathlib.join(config.workDir, INSTALLED_FILE), '', 'utf8'); diff --git a/packages/lit-dev-tools-esm/src/generate-js-samples.ts b/packages/lit-dev-tools-esm/src/generate-js-samples.ts index f1c61a137..bd05d0aaf 100644 --- a/packages/lit-dev-tools-esm/src/generate-js-samples.ts +++ b/packages/lit-dev-tools-esm/src/generate-js-samples.ts @@ -138,7 +138,7 @@ const tsCompileOpts: InvokeTypeScriptOpts = { const playgroundCommentRegexp = /\/\*\s*(playground-(fold|hide)(-end)?)\s\*\//g; const tsPath = jsPath - .replace(/^samples\/js\//, 'samples/') + .replace(/^samples\/js\/|^samples\\js\\/, `samples${pathlib.sep}`) .replace(/\.js$/, '.ts') .replace(/\.jsx$/, '.tsx'); const ts = fsSync.readFileSync(tsPath, 'utf8');