@tsmodule/tsmodule 15.1.0 → 17.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/commands/build/index.js +3 -3
- package/dist/commands/create/index.js +1 -1
- package/dist/commands/dev/index.js +3 -3
- package/dist/commands/execute/index.js +1 -1
- package/dist/commands/normalize/index.js +2 -2
- package/dist/index.js +1 -1
- package/dist/loader/index.js +1 -1
- package/dist/package.json +3 -0
- package/dist/utils/pkgJson.js +1 -1
- package/package.json +5 -5
- package/templates/default/.eslintrc +52 -0
- package/templates/default/.github/workflows/ci.yml +30 -0
- package/templates/default/.gitignore +10 -0
- package/templates/default/README.md +5 -0
- package/templates/default/package.json +35 -0
- package/templates/default/src/index.ts +4 -0
- package/templates/default/test/example.test.ts +7 -0
- package/templates/default/tsconfig.json +41 -0
- package/templates/react/.eslintrc +54 -0
- package/templates/react/.gitignore +11 -0
- package/templates/react/next-env.d.ts +5 -0
- package/templates/react/next.config.js +18 -0
- package/templates/react/package.json +38 -0
- package/templates/react/postcss.config.js +6 -0
- package/templates/react/src/components/Card/index.tsx +13 -0
- package/templates/react/src/components/CardGrid/index.tsx +29 -0
- package/templates/react/src/components/Footer/index.tsx +19 -0
- package/templates/react/src/components/GetStarted/index.tsx +8 -0
- package/templates/react/src/components/Welcome/index.tsx +7 -0
- package/templates/react/src/components/index.ts +4 -0
- package/templates/react/src/index.ts +1 -0
- package/templates/react/src/pages/_app.tsx +13 -0
- package/templates/react/src/pages/api/hello.ts +13 -0
- package/templates/react/src/pages/index.tsx +26 -0
- package/templates/react/src/styles/custom/index.css +0 -0
- package/templates/react/src/styles/elements/card/index.css +14 -0
- package/templates/react/src/styles/elements/index.css +1 -0
- package/templates/react/src/styles/index.css +253 -0
- package/templates/react/src/styles/viewport/index.css +26 -0
- package/templates/react/src/utils/globs.ts +1 -0
- package/templates/react/tailwind.config.js +21 -0
@@ -1,3 +1,3 @@
|
|
1
|
-
import{build as T}from"esbuild";import{
|
2
|
-
`}}),
|
3
|
-
This might take a moment.`)
|
1
|
+
import{build as T}from"esbuild";import{extname as E,isAbsolute as F,resolve as N,resolve as u}from"path";import{existsSync as O,readFileSync as x,rmSync as h,writeFileSync as D}from"fs";import l from"chalk";import{copy as P}from"fs-extra";import{env as w}from"process";import B from"fast-glob";import c from"ora";import{createDebugLogger as C,log as d}from"create-debug-logger";import{isJsOrTs as W,isTs as m,isTsxOrJsx as a}from"../../utils/index.js";import{emitTsDeclarations as $}from"./lib/emitTsDeclarations.js";import{getPackageJsonFile as v}from"../../utils/pkgJson.js";import{normalizeImportSpecifiers as G}from"../normalize/index.js";const J=t=>{const s=` ${t} `;d(l.bgBlue(l.bold(l.white(s))))},_=()=>{let t;if(O("dist/package.json")?t=JSON.parse(x("dist/package.json","utf-8")):t={},t?.module==="module")return!0;t.type="module",D("dist/package.json",JSON.stringify(t,null,2))},A=async({files:t="src/**/*",dev:s=!1,fast:g=!1})=>{w.NODE_ENV=s?"development":"production";const r=C(A);r.log("Building",{files:t,dev:s,fast:g}),J(`${l.bold("TS Module")} [${w.NODE_ENV}]`);const k=await v(),i=process.cwd(),f={absWorkingDir:i,outbase:"src",outdir:"dist",assetNames:"[name].js",logLevel:s?"warning":"error",charset:"utf8",format:"esm",target:"esnext",minify:!s,define:{PACKAGE_JSON:k}},p=u(i,"src"),n=u(i,"dist"),o=B.sync(t,{cwd:i}).filter(e=>E(e)!==".d.ts").map(e=>u(e));if(F(t)){o.length||o.push(t);const e=t.replace(p,n).replace(m,".js").replace(a,".js");r.log("Cleaning emitted file:",{outfile:e}),h(e,{force:!0})}else r.log("Cleaning old output:",{outDir:n}),h(n,{force:!0,recursive:!0});console.log();const y=o.filter(e=>m.test(e)).filter(e=>!a.test(e));r.log("Compiling TS files:",{tsFiles:y}),await T({...f,entryPoints:y.filter(e=>!e.endsWith(".d.ts"))}),c("Built TS files.").succeed();const S=o.filter(e=>a.test(e));r.log("Compiling TSX files:",{tsxFiles:S}),await T({...f,entryPoints:S.filter(e=>!e.endsWith(".d.ts")),jsxFactory:"createElement",banner:{js:`import { createElement } from "react";
|
2
|
+
`}}),c("Built TSX files.").succeed();const b=o.filter(e=>!W.test(e));if(r.log("Copying non-JS/TS files.",{allFiles:o,nonJsTsFiles:b}),await Promise.all(b.map(async e=>{const j=N(i,e).replace(p,n).replace(m,".js").replace(a,".js");r.log("Copying non-source file:",{file:e,outfile:j}),await P(e,j)})),!process.env.NO_REWRITES){const e=t.replace(p,n).replace(/^(\.\/)?src\//,"dist/").replace(m,".js").replace(a,".js");await G(e.endsWith(".js")?e:`${e}.js`),c("Normalized import specifiers.").succeed()}_()&&c('Forced "type": "module" in output.').succeed(),console.log(),!(s||g)&&(J("Running post-build setup."),d(`Generating type declarations.
|
3
|
+
This might take a moment.`),$(o),c(`Generated delcarations for ${o.length} files.`).succeed(),d(l.green("Build complete.")))};export{J as bannerLog,A as build};
|
@@ -1 +1 @@
|
|
1
|
-
import o from"chalk";import c
|
1
|
+
import o from"chalk";import{createShell as c}from"await-shell";import d from"ora";import{createTemplate as a}from"./lib/createTemplate.js";import{rewritePkgJson as l}from"./lib/rewritePkgJson.js";globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};const w=async(e,{react:s=!1})=>{const i=c(),t=d(`Creating new module ${o.blueBright(e)}.`).start();await a("default",e),s&&await a("react",e),await l(e),t.succeed("Project created. Installing dependencies."),process.chdir(e);const n=[],r=["@tsmodule/tsmodule"];s&&(n.push("react","react-dom"),r.push("next","eslint-config-next","tailwindcss","postcss","autoprefixer")),n.length&&await i.run(`yarn add ${n.join(" ")}`),r.length&&await i.run(`yarn add -D ${r.join(" ")}`),t.succeed("Dependencies installed. Initializing git."),await i.run("git init"),t.succeed("Git initialized.")};export{w as create};
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import{relative as a,resolve as m}from"path";import{build as
|
2
|
-
`,
|
3
|
-
`,
|
1
|
+
import{relative as a,resolve as m}from"path";import{build as s}from"../build/index.js";import r from"chalk";import{createShell as p}from"await-shell";import{existsSync as u,lstatSync as f}from"fs";import{log as d}from"create-debug-logger";import w from"ora";import g from"node-watch";const o=()=>{console.clear()},i=t=>{d(`
|
2
|
+
`,r.gray(`Built ${r.bold(t)}.`),`
|
3
|
+
`,r.blue(new Date().toLocaleString()))},L=async()=>{const t=process.cwd(),n=p();process.platform!=="win32"&&await n.run("clear"),o(),await s({dev:!0}),i("src/**/*"),g(m(t,"src"),{recursive:!0,persistent:!0}).on("change",async(v,e)=>{if(!u(e)||!f(e).isFile())return;o();const c=Date.now();await s({dev:!0,files:e});const l=Date.now()-c;w(r.blueBright(`Dev refresh finished in ${r.bold(`${l}ms`)}.`)).succeed(),i(a(t,e))})};export{L as dev};
|
@@ -1 +1 @@
|
|
1
|
-
import{URL as n}from"url";import{
|
1
|
+
import{URL as n}from"url";import{createShell as s}from"await-shell";const i=async()=>{const e=import.meta.url,o=new n("../../../dist/loader/index.js",e),r=["--no-warnings","--loader",o.href,...process.argv.slice(2)];await s().run(`node ${r.join(" ")}`)};export{i as execute};
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{
|
2
|
-
\r;]*`,o=t.replace(".","\\.").replace("/","\\/"),
|
1
|
+
import{readFileSync as w,writeFileSync as $}from"fs";import y from"fast-glob";import{pathToFileURL as S}from"url";import{resolve as x}from"path";import{createDebugLogger as g}from"create-debug-logger";import{getRewrittenSpecifiers as E}from"./lib/typescriptApi.js";const I=t=>{const r=`[^
|
2
|
+
\r;]*`,o=t.replace(".","\\.").replace("/","\\/"),s=`${r}["']${o}["']${r}`,e=`(import${r}from)`,i=`(import|require)${r}\\(`,n=`(export${r}from)`;return new RegExp(`(${e}|${i}|${n})${s}`,"g")},d=(t,r,o)=>{g(d).log("Rewriting import",{importStatement:t,specifierToReplace:r,specifierReplacement:o});const[,e]=t.split(/from|\(/),i=e.replace(r,o).trim();return t.replace(e,i)},P=async(t="dist/**/*.js")=>{const r=g(P),o=await y(t,{cwd:process.cwd()});r.log("Normalizing import/require specifiers:",{filesToNormalize:o});for(const s of o){const e=x(s),i=S(e).href,n=E(e);if(!n)return null;r.log("TypeScript API yielded specifiers to rewrite:",{rewrites:n});let c=w(e,"utf8");r.group();for(const{specifierToReplace:p,specifierReplacement:l}of n){const u=I(p),a=c.match(u)??[];r.log("Replacing import statements.",{entryPointURL:i,specifierToReplace:p,specifierReplacement:l,importStatements:a});for(const m of a){r.group();const f=d(m,p,l);r.log("Performing specifier rewrite.",{entryPointURL:i,importStatement:m,rewrittenImportStatement:f}),c=c.replace(m,f),$(e,c),r.log("Wrote output file.",{resolvedEntryPoint:e}),r.groupEnd()}}r.groupEnd()}};export{I as generateImportPattern,P as normalizeImportSpecifiers,d as rewriteImportStatement};
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
var r="@tsmodule/tsmodule",a="module",m="
|
2
|
+
var r="@tsmodule/tsmodule",a="module",m="17.0.2",d="tsmodule/tsmodule",s="TypeScript Module loader and compiler",l="MIT",c={tsmodule:"dist/index.js"},p={".":"./dist/loader/index.js","./*":"./dist/*/index.js","./package.json":"./package.json"},u="dist/types/index.d.ts",f=[{name:"C. Lewis",email:"ctj.lewis@icloud.com",url:"https://ctjlewis.com"}],b=["dist/","templates/"],v={node:">=14"},g={bootstrap:"node bootstrap.js",bootload:"node --no-warnings --loader ./dist/loader/index.js src/index.ts build -f",prebuild:"yarn bootstrap && yarn bootload && yarn link -f",build:"tsmodule build",dev:"tsmodule dev",lint:"eslint --fix src",prepare:"yarn build -f",prepublishOnly:"yarn build && yarn test",pretest:"yarn build -f",test:"ava --no-worker-threads"},h={"@types/glob":"^7.2.0","@types/node":"^17.0.15","@typescript-eslint/eslint-plugin":"^5.9.1","@typescript-eslint/parser":"^5.9.1",ava:"^4.0.1","await-shell":"^29.0.1-0",chalk:"^5.0.0",commander:"^8.3.0","create-debug-logger":"^1.10.1",esbuild:"^0.14.0",eslint:"^8.8.0","fast-glob":"^3.2.10","fs-extra":"^10.0.0",glob:"^7.2.0","node-watch":"^0.7.3",ora:"^6.0.1",path:"^0.12.7",typescript:"^4.5.5"},S=["esm","loader","typescript","loader hook","require hook","experimental-loader"],w={timeout:"10 minutes",files:["test/**/*.test.ts"],extensions:{ts:"module"},nodeArguments:["--no-warnings","--loader=@tsmodule/tsmodule"]},y={"@types/fs-extra":"^9.0.13"},t={name:r,type:a,version:m,repository:d,description:s,license:l,bin:c,exports:p,types:u,contributors:f,files:b,engines:v,scripts:g,dependencies:h,keywords:S,ava:w,devDependencies:y};import e from"chalk";import{Command as T}from"commander";import{build as B}from"./commands/build/index.js";import{create as C}from"./commands/create/index.js";import{dev as R}from"./commands/dev/index.js";import{execute as j}from"./commands/execute/index.js";import{normalizeImportSpecifiers as x}from"./commands/normalize/index.js";const{version:A}=t,i=new T;i.name(e.white(e.bold("tsmodule"))).usage(e.white(e.bold("<file | command> [options]"))).description(e.blueBright(`A tool for building TypeScript modules.
|
3
3
|
|
4
4
|
Run TS directly: ${e.bold("tsmodule src/index.ts")}
|
5
5
|
Use a command: ${e.bold("tsmodule build")}`)).version(String(A)),i.command("dev").description("Build and watch for changes.").action(R),i.command("build").option("--files <files>","The files to build (default: all)").option("-d, --dev","Build development version").option("-f, --fast","Do not emit type declarations, only transform to JS").description("Builds TS files to output in dist/.").action(B),i.command("create <name>").option("--react","Create React component library with Next.js").description("Create a new project.").action(C),i.command("normalize [files]").description(`Rewrites import specifiers in files to ESM-compliant paths.
|
package/dist/loader/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{extname as m,isAbsolute as U,join as E,normalize as
|
1
|
+
import{extname as m,isAbsolute as U,join as E,normalize as S,resolve as w}from"path";import{fileURLToPath as H,pathToFileURL as v,URL as L}from"url";import{createDebugLogger as d}from"create-debug-logger";import{readFileSync as G}from"fs";import{transform as h}from"esbuild";import{posix as M}from"path";import{win32 as T}from"path";import{checkExtensions as k,checkTsExtensions as D,fileExists as b,isJs as y,isTs as N,MODULE_LOADERS as R}from"../utils/index.js";import{getPackageJsonFile as P}from"../utils/pkgJson.js";const F=await P(),A=async(o,r,t)=>{const{parentURL:s}=r,e=d(A);if(e.log("Resolving specifier:",{importedFromURL:s,specifier:o}),!o.startsWith(".")&&!U(o))return e.log("Using defaultResolve for named module:",{specifier:o}),t(o,r,t);const{href:l}=v(process.cwd()),{href:i}=new L(s||l);e.log("Finding import URL for",{specifier:o,baseURL:i});let n=o;o.startsWith("file://")||(U(o)?(e.log("Setting import URL to absolute specifier."),n=v(w(S(o))).href):(e.log("Setting import URL relative to baseURL."),n=new L(o,i).href),e.log("Resolved import URL:",{importedFileURL:n,importedFromURL:s}));const f=m(s??"").toLowerCase(),c=m(n).toLowerCase();if(e.log("Rewriting file extension:",{parentExtension:f,specifierExtension:c}),c){const a=n.substring(0,n.lastIndexOf(c));if(e.log("Re-resolving specifier:",{unresolvedSpecifier:a}),y.test(c)&&N.test(f)){const p=D(a);if(p)return e.log("Found JS import in TS:",{unresolvedSpecifier:a,resolvedTsSourceFile:p}),{url:p}}return b(a)?(e.log("Found file at unresolved specifier:",{unresolvedSpecifier:a}),{url:a}):t(o,r,t)}e.log("Resolving incomplete URL import to file:",{specifier:o});const u=k(n);if(u)return e.log("Resolved import URL to file:",{resolvedFile:u}),{url:u};const x=new L(E(n,"index")).href,g=k(x);return g?(e.log("Resolved import URL to index file:",{resolvedIndexFile:g}),{url:g}):t(o,r,t)},J=async(o,r,t)=>{const s=d(J);if(s.log("Loading source file:",{url:o}),!o.includes(T.sep)&&!o.includes(M.sep))return s.log("Using defaultLoad for named module:",{url:o}),t(o,r,t);const e=m(o),l=R[e];if(!l)return s.log("No loader found, using defaultLoad:",{url:o}),t(o,r,t);const i=H(o),n=G(i,"utf8"),f=await h(n.toString(),{...l,sourcefile:i,format:"esm",define:{PACKAGE_JSON:F}});return{format:"module",source:f.code}},O=async(o,r,t)=>{const s=d(O);s.log("Getting format for source file:",{url:o});const e=m(o);return R[e]?{format:"module"}:(s.log("No loader found, using default format:",{url:o}),t(o,r,t))},B=async(o,r,t)=>{const s=d(B);s.log("Transforming source from context:",{context:r});const{url:e}=r,l=m(e),i=R[l];return i?{source:(await h(o.toString(),{...i,logLevel:"info",charset:"utf8",target:"esnext",sourcefile:r.url,format:r.format==="module"?"esm":"cjs",define:{PACKAGE_JSON:F}})).code}:(s.log("No loader found, using default transformer:",{url:e}),t(o,r,t))};export{O as getFormat,J as load,A as resolve,B as transformSource};
|
package/dist/utils/pkgJson.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{
|
1
|
+
import{readFileSync as c}from"fs";import{resolve as r}from"path";const a=async()=>{const o=process.cwd(),e=r(o,"package.json");return c(e,"utf-8")};export{a as getPackageJsonFile};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tsmodule/tsmodule",
|
3
3
|
"type": "module",
|
4
|
-
"version": "
|
4
|
+
"version": "17.0.2",
|
5
5
|
"repository": "tsmodule/tsmodule",
|
6
6
|
"description": "TypeScript Module loader and compiler",
|
7
7
|
"license": "MIT",
|
@@ -23,7 +23,7 @@
|
|
23
23
|
],
|
24
24
|
"files": [
|
25
25
|
"dist/",
|
26
|
-
"
|
26
|
+
"templates/"
|
27
27
|
],
|
28
28
|
"engines": {
|
29
29
|
"node": ">=14"
|
@@ -41,13 +41,12 @@
|
|
41
41
|
"test": "ava --no-worker-threads"
|
42
42
|
},
|
43
43
|
"dependencies": {
|
44
|
+
"@types/glob": "^7.2.0",
|
44
45
|
"@types/node": "^17.0.15",
|
45
|
-
"@types/react": "^17.0.39",
|
46
|
-
"@types/react-dom": "^17.0.11",
|
47
46
|
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
48
47
|
"@typescript-eslint/parser": "^5.9.1",
|
49
48
|
"ava": "^4.0.1",
|
50
|
-
"await-shell": "^
|
49
|
+
"await-shell": "^29.0.1-0",
|
51
50
|
"chalk": "^5.0.0",
|
52
51
|
"commander": "^8.3.0",
|
53
52
|
"create-debug-logger": "^1.10.1",
|
@@ -55,6 +54,7 @@
|
|
55
54
|
"eslint": "^8.8.0",
|
56
55
|
"fast-glob": "^3.2.10",
|
57
56
|
"fs-extra": "^10.0.0",
|
57
|
+
"glob": "^7.2.0",
|
58
58
|
"node-watch": "^0.7.3",
|
59
59
|
"ora": "^6.0.1",
|
60
60
|
"path": "^0.12.7",
|
@@ -0,0 +1,52 @@
|
|
1
|
+
{
|
2
|
+
"extends": [
|
3
|
+
"plugin:@typescript-eslint/recommended"
|
4
|
+
],
|
5
|
+
"parser": "@typescript-eslint/parser",
|
6
|
+
"plugins": ["@typescript-eslint"],
|
7
|
+
"rules": {
|
8
|
+
|
9
|
+
"no-console": "error",
|
10
|
+
"no-trailing-spaces": "error",
|
11
|
+
"max-len": [1, 80, 2, {
|
12
|
+
"ignorePattern": "^import\\s.+\\sfrom\\s.+;$",
|
13
|
+
"ignoreUrls": true,
|
14
|
+
"ignoreStrings": true,
|
15
|
+
"ignoreTemplateLiterals": true,
|
16
|
+
"ignoreRegExpLiterals": true
|
17
|
+
}],
|
18
|
+
|
19
|
+
"@typescript-eslint/type-annotation-spacing": ["error"],
|
20
|
+
|
21
|
+
"@typescript-eslint/ban-ts-comment": [
|
22
|
+
"error",
|
23
|
+
{
|
24
|
+
"ts-nocheck": "allow-with-description",
|
25
|
+
"ts-ignore": "allow-with-description"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
|
29
|
+
"indent": "off",
|
30
|
+
"@typescript-eslint/indent": ["error", 2],
|
31
|
+
|
32
|
+
"semi": "off",
|
33
|
+
"@typescript-eslint/semi": ["error", "always"],
|
34
|
+
|
35
|
+
"quotes": "off",
|
36
|
+
"@typescript-eslint/quotes": ["error", "double"],
|
37
|
+
|
38
|
+
"object-curly-spacing": "off",
|
39
|
+
"@typescript-eslint/object-curly-spacing": ["error", "always"],
|
40
|
+
|
41
|
+
"sort-imports": [
|
42
|
+
"warn",
|
43
|
+
{
|
44
|
+
"ignoreCase": false,
|
45
|
+
"ignoreDeclarationSort": false,
|
46
|
+
"ignoreMemberSort": true,
|
47
|
+
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
|
48
|
+
"allowSeparatedGroups": true
|
49
|
+
}
|
50
|
+
]
|
51
|
+
}
|
52
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- '**'
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- '**'
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test:
|
13
|
+
name: Node ${{ matrix.nodejs }} on ${{ matrix.os }}
|
14
|
+
runs-on: ${{ matrix.os }}
|
15
|
+
timeout-minutes: 10
|
16
|
+
strategy:
|
17
|
+
matrix:
|
18
|
+
nodejs: [14, 16, "lts/*"]
|
19
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
- uses: actions/setup-node@v2
|
23
|
+
with:
|
24
|
+
node-version: ${{ matrix.nodejs }}
|
25
|
+
|
26
|
+
- name: Install and link
|
27
|
+
run: yarn install --frozen-lockfile && yarn build
|
28
|
+
|
29
|
+
- name: Test
|
30
|
+
run: yarn test
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"name": "template",
|
3
|
+
"type": "module",
|
4
|
+
"version": "0.0.1",
|
5
|
+
"license": "MIT",
|
6
|
+
"types": "dist/index.d.ts",
|
7
|
+
"files": [
|
8
|
+
"dist"
|
9
|
+
],
|
10
|
+
"exports": {
|
11
|
+
"./package.json": "./package.json",
|
12
|
+
".": "./dist/index.js",
|
13
|
+
"./*": "./dist/*/index.js"
|
14
|
+
},
|
15
|
+
"scripts": {
|
16
|
+
"build": "tsmodule build",
|
17
|
+
"test": "ava",
|
18
|
+
"lint": "eslint src --fix",
|
19
|
+
"pretest": "tsmodule build -f",
|
20
|
+
"prepublishOnly": "yarn build && yarn test"
|
21
|
+
},
|
22
|
+
"ava": {
|
23
|
+
"timout": 240000,
|
24
|
+
"files": [
|
25
|
+
"test/**/*.test.ts"
|
26
|
+
],
|
27
|
+
"extensions": {
|
28
|
+
"ts": "module"
|
29
|
+
},
|
30
|
+
"nodeArguments": [
|
31
|
+
"--no-warnings",
|
32
|
+
"--loader=@tsmodule/tsmodule"
|
33
|
+
]
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"include": [
|
3
|
+
"*env.d.ts",
|
4
|
+
"src/**/*"
|
5
|
+
],
|
6
|
+
"exclude": [
|
7
|
+
"node_modules",
|
8
|
+
"test/**"
|
9
|
+
],
|
10
|
+
"compilerOptions": {
|
11
|
+
"moduleResolution": "Node",
|
12
|
+
"target": "ESNext",
|
13
|
+
"module": "ESNext",
|
14
|
+
"lib": [
|
15
|
+
"DOM",
|
16
|
+
"DOM.Iterable",
|
17
|
+
"ESNext"
|
18
|
+
],
|
19
|
+
"jsx": "preserve",
|
20
|
+
"rootDir": "src",
|
21
|
+
"outDir": "dist",
|
22
|
+
"allowJs": true,
|
23
|
+
"importHelpers": true,
|
24
|
+
"esModuleInterop": true,
|
25
|
+
"allowSyntheticDefaultImports": true,
|
26
|
+
"strict": true,
|
27
|
+
"noUnusedLocals": true,
|
28
|
+
"noUnusedParameters": true,
|
29
|
+
"noImplicitReturns": true,
|
30
|
+
"noFallthroughCasesInSwitch": true,
|
31
|
+
"skipLibCheck": true,
|
32
|
+
"resolveJsonModule": true,
|
33
|
+
"declaration": true,
|
34
|
+
"sourceMap": true,
|
35
|
+
"checkJs": true,
|
36
|
+
"noEmit": false,
|
37
|
+
"forceConsistentCasingInFileNames": true,
|
38
|
+
"isolatedModules": true,
|
39
|
+
"incremental": false
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
{
|
2
|
+
"extends": [
|
3
|
+
"plugin:@typescript-eslint/recommended",
|
4
|
+
"next",
|
5
|
+
"next/core-web-vitals"
|
6
|
+
],
|
7
|
+
"parser": "@typescript-eslint/parser",
|
8
|
+
"plugins": ["@typescript-eslint"],
|
9
|
+
"rules": {
|
10
|
+
|
11
|
+
"no-console": "error",
|
12
|
+
"no-trailing-spaces": "error",
|
13
|
+
"max-len": [1, 80, 2, {
|
14
|
+
"ignorePattern": "^import\\s.+\\sfrom\\s.+;$",
|
15
|
+
"ignoreUrls": true,
|
16
|
+
"ignoreStrings": true,
|
17
|
+
"ignoreTemplateLiterals": true,
|
18
|
+
"ignoreRegExpLiterals": true
|
19
|
+
}],
|
20
|
+
|
21
|
+
"@typescript-eslint/type-annotation-spacing": ["error"],
|
22
|
+
|
23
|
+
"@typescript-eslint/ban-ts-comment": [
|
24
|
+
"error",
|
25
|
+
{
|
26
|
+
"ts-nocheck": "allow-with-description",
|
27
|
+
"ts-ignore": "allow-with-description"
|
28
|
+
}
|
29
|
+
],
|
30
|
+
|
31
|
+
"indent": "off",
|
32
|
+
"@typescript-eslint/indent": ["error", 2],
|
33
|
+
|
34
|
+
"semi": "off",
|
35
|
+
"@typescript-eslint/semi": ["error", "always"],
|
36
|
+
|
37
|
+
"quotes": "off",
|
38
|
+
"@typescript-eslint/quotes": ["error", "double"],
|
39
|
+
|
40
|
+
"object-curly-spacing": "off",
|
41
|
+
"@typescript-eslint/object-curly-spacing": ["error", "always"],
|
42
|
+
|
43
|
+
"sort-imports": [
|
44
|
+
"warn",
|
45
|
+
{
|
46
|
+
"ignoreCase": false,
|
47
|
+
"ignoreDeclarationSort": false,
|
48
|
+
"ignoreMemberSort": true,
|
49
|
+
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
|
50
|
+
"allowSeparatedGroups": true
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module.exports = {
|
2
|
+
reactStrictMode: true,
|
3
|
+
webpack: (config) => {
|
4
|
+
// config.experiments = { topLevelAwait: true };
|
5
|
+
// config.resolve.fallback = {
|
6
|
+
// assert: false,
|
7
|
+
// process: false,
|
8
|
+
// events: false,
|
9
|
+
// fs: false,
|
10
|
+
// util: false,
|
11
|
+
// path: false,
|
12
|
+
// stream: false,
|
13
|
+
// constants: false,
|
14
|
+
// os: false,
|
15
|
+
// };
|
16
|
+
return config;
|
17
|
+
},
|
18
|
+
};
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"name": "template",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"license": "MIT",
|
5
|
+
"types": "dist/index.d.ts",
|
6
|
+
"files": [
|
7
|
+
"dist"
|
8
|
+
],
|
9
|
+
"exports": {
|
10
|
+
".": "./dist/index.js",
|
11
|
+
"./styles": "./dist/styles/index.css",
|
12
|
+
"./styles/*": "./dist/styles/*/index.css",
|
13
|
+
"./package.json": "./package.json",
|
14
|
+
"./*": "./dist/components/*/index.js"
|
15
|
+
},
|
16
|
+
"scripts": {
|
17
|
+
"export": "tsmodule build",
|
18
|
+
"dev": "next dev",
|
19
|
+
"build": "next build",
|
20
|
+
"start": "next start",
|
21
|
+
"lint": "next lint --fix",
|
22
|
+
"test": "ava",
|
23
|
+
"prepublishOnly": "yarn build && yarn test"
|
24
|
+
},
|
25
|
+
"ava": {
|
26
|
+
"timout": 240000,
|
27
|
+
"files": [
|
28
|
+
"test/**/*.test.ts"
|
29
|
+
],
|
30
|
+
"extensions": {
|
31
|
+
"ts": "module"
|
32
|
+
},
|
33
|
+
"nodeArguments": [
|
34
|
+
"--no-warnings",
|
35
|
+
"--loader=@tsmodule/tsmodule"
|
36
|
+
]
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { Card } from "../Card";
|
2
|
+
|
3
|
+
export const CardGrid = () => {
|
4
|
+
return (
|
5
|
+
<div className="grid md:grid-cols-2">
|
6
|
+
<a href="https://nextjs.org/docs" className="card">
|
7
|
+
<h4>Documentation →</h4>
|
8
|
+
<p>Find in-depth information about Next.js features and API.</p>
|
9
|
+
</a>
|
10
|
+
|
11
|
+
<Card href="https://nextjs.org/learn">
|
12
|
+
<h4>Learn →</h4>
|
13
|
+
<p>Learn about Next.js in an interactive course with quizzes!</p>
|
14
|
+
</Card>
|
15
|
+
|
16
|
+
<Card href="https://github.com/vercel/next.js/tree/master/examples">
|
17
|
+
<h4>Examples →</h4>
|
18
|
+
<p>Discover and deploy boilerplate example Next.js projects.</p>
|
19
|
+
</Card>
|
20
|
+
|
21
|
+
<Card href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app">
|
22
|
+
<h4>Deploy →</h4>
|
23
|
+
<p>
|
24
|
+
Instantly deploy your Next.js site to a public URL with Vercel.
|
25
|
+
</p>
|
26
|
+
</Card>
|
27
|
+
</div>
|
28
|
+
);
|
29
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import Image from "next/image";
|
2
|
+
|
3
|
+
export const Footer = () => {
|
4
|
+
return (
|
5
|
+
<footer>
|
6
|
+
<a
|
7
|
+
className="flex-center"
|
8
|
+
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
9
|
+
target="_blank"
|
10
|
+
rel="noopener noreferrer"
|
11
|
+
>
|
12
|
+
Powered by{" "}
|
13
|
+
<span className="h-4 ml-2 flex-center">
|
14
|
+
<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
|
15
|
+
</span>
|
16
|
+
</a>
|
17
|
+
</footer>
|
18
|
+
);
|
19
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./components";
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import "../styles/index.css";
|
2
|
+
import type { AppProps } from "next/app";
|
3
|
+
import { StrictMode } from "react";
|
4
|
+
|
5
|
+
function MyApp({ Component, pageProps }: AppProps) {
|
6
|
+
return (
|
7
|
+
<StrictMode>
|
8
|
+
<Component {...pageProps} />
|
9
|
+
</StrictMode>
|
10
|
+
);
|
11
|
+
}
|
12
|
+
|
13
|
+
export default MyApp;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
2
|
+
import type { NextApiRequest, NextApiResponse } from "next";
|
3
|
+
|
4
|
+
type Data = {
|
5
|
+
name: string
|
6
|
+
};
|
7
|
+
|
8
|
+
export default function handler(
|
9
|
+
_: NextApiRequest,
|
10
|
+
res: NextApiResponse<Data>
|
11
|
+
) {
|
12
|
+
res.status(200).json({ name: "John Doe" });
|
13
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import Head from "next/head";
|
2
|
+
|
3
|
+
import { CardGrid } from "../components/CardGrid";
|
4
|
+
import { Footer } from "../components/Footer";
|
5
|
+
import { GetStarted } from "../components/GetStarted";
|
6
|
+
import { Welcome } from "../components/Welcome";
|
7
|
+
|
8
|
+
export default function Home() {
|
9
|
+
return (
|
10
|
+
<>
|
11
|
+
<Head>
|
12
|
+
<title>Create Next App</title>
|
13
|
+
<meta name="description" content="Generated by create next app" />
|
14
|
+
<link rel="icon" href="/favicon.ico" />
|
15
|
+
</Head>
|
16
|
+
|
17
|
+
<main>
|
18
|
+
<Welcome />
|
19
|
+
<GetStarted />
|
20
|
+
<CardGrid />
|
21
|
+
</main>
|
22
|
+
|
23
|
+
<Footer />
|
24
|
+
</>
|
25
|
+
);
|
26
|
+
}
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
.card {
|
2
|
+
@apply m-4 p-6 text-left rounded-lg;
|
3
|
+
text-decoration: none;
|
4
|
+
border: 1px solid #eaeaea;
|
5
|
+
transition: color 0.15s ease, border-color 0.15s ease;
|
6
|
+
/* max-width: 300px; */
|
7
|
+
}
|
8
|
+
|
9
|
+
.card:hover,
|
10
|
+
.card:focus,
|
11
|
+
.card:active {
|
12
|
+
color: #0070f3;
|
13
|
+
border-color: #0070f3;
|
14
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
@import './card/index.css';
|
@@ -0,0 +1,253 @@
|
|
1
|
+
@tailwind base;
|
2
|
+
@tailwind components;
|
3
|
+
@tailwind utilities;
|
4
|
+
|
5
|
+
/* FONTS: Customize */
|
6
|
+
@layer base {
|
7
|
+
/* Style your serif font here. */
|
8
|
+
.serif {
|
9
|
+
font-family: serif;
|
10
|
+
}
|
11
|
+
|
12
|
+
/* Style your sans font here. */
|
13
|
+
.sans-serif {
|
14
|
+
font-family: sans-serif;
|
15
|
+
}
|
16
|
+
|
17
|
+
/* Style your display font here. */
|
18
|
+
.display {}
|
19
|
+
|
20
|
+
/* Style your interface font here. */
|
21
|
+
.interface {
|
22
|
+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
|
23
|
+
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
/* DEFAULT BODY FONT */
|
28
|
+
@layer base {
|
29
|
+
html, body {
|
30
|
+
@apply font-size-sm interface;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
/* LINKS */
|
35
|
+
@layer base {
|
36
|
+
a {
|
37
|
+
@apply underline;
|
38
|
+
color: inherit;
|
39
|
+
text-decoration: none;
|
40
|
+
}
|
41
|
+
|
42
|
+
h1 a,
|
43
|
+
h2 a,
|
44
|
+
h3 a,
|
45
|
+
h4 a,
|
46
|
+
h5 a,
|
47
|
+
h6 a {
|
48
|
+
color: #0070f3;
|
49
|
+
}
|
50
|
+
|
51
|
+
/* If the user can hover, transition in by default. */
|
52
|
+
@media (hover: hover) {
|
53
|
+
a {
|
54
|
+
transition: 300ms;
|
55
|
+
text-decoration: underline;
|
56
|
+
text-decoration-color: transparent;
|
57
|
+
}
|
58
|
+
|
59
|
+
a:hover {
|
60
|
+
text-decoration-color: inherit;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
/* FONT SIZES */
|
66
|
+
@layer base {
|
67
|
+
.font-size-1 {
|
68
|
+
@apply text-4xl sm:text-5xl 2xl:text-6xl 4xl:text-8xl;
|
69
|
+
}
|
70
|
+
|
71
|
+
.font-size-2 {
|
72
|
+
@apply text-2xl sm:text-4xl 2xl:text-5xl 4xl:text-6xl;
|
73
|
+
}
|
74
|
+
|
75
|
+
.font-size-3 {
|
76
|
+
@apply text-xl sm:text-2xl 2xl:text-4xl 4xl:text-5xl;
|
77
|
+
}
|
78
|
+
|
79
|
+
.font-size-base {
|
80
|
+
@apply text-lg sm:text-xl 2xl:text-2xl 4xl:text-3xl;
|
81
|
+
}
|
82
|
+
|
83
|
+
.font-size-sm {
|
84
|
+
@apply text-base 2xl:text-lg 4xl:text-2xl;
|
85
|
+
}
|
86
|
+
|
87
|
+
.font-size-xs {
|
88
|
+
@apply text-sm 2xl:text-base 4xl:text-lg;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
/* HEADINGS */
|
93
|
+
@layer base {
|
94
|
+
h1, .h1,
|
95
|
+
h2, .h2,
|
96
|
+
h3, .h3,
|
97
|
+
h4, .h4,
|
98
|
+
h5, .h5,
|
99
|
+
h6, .h6 {
|
100
|
+
@apply font-bold display;
|
101
|
+
@apply pb-2 leading-snug;
|
102
|
+
}
|
103
|
+
|
104
|
+
h1, .h1 {
|
105
|
+
@apply font-size-1;
|
106
|
+
}
|
107
|
+
|
108
|
+
h2, .h2 {
|
109
|
+
@apply font-size-2;
|
110
|
+
}
|
111
|
+
|
112
|
+
h3, .h3 {
|
113
|
+
@apply font-size-3;
|
114
|
+
}
|
115
|
+
|
116
|
+
h4, .h4 {
|
117
|
+
@apply font-size-base;
|
118
|
+
}
|
119
|
+
|
120
|
+
h5, .h5 {
|
121
|
+
@apply font-size-sm;
|
122
|
+
}
|
123
|
+
|
124
|
+
h6, .h6 {
|
125
|
+
@apply font-size-xs;
|
126
|
+
}
|
127
|
+
|
128
|
+
.title {
|
129
|
+
@apply mt-2 display font-bold;
|
130
|
+
}
|
131
|
+
|
132
|
+
.title p {
|
133
|
+
@apply p-0 m-0;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
/* FLEX */
|
138
|
+
@layer base {
|
139
|
+
/**
|
140
|
+
* A container that fills its parent.
|
141
|
+
*/
|
142
|
+
.expanded {
|
143
|
+
@apply h-full w-full;
|
144
|
+
}
|
145
|
+
/**
|
146
|
+
* Flex container that fills its content.
|
147
|
+
*/
|
148
|
+
.filled {
|
149
|
+
@apply flex flex-1 items-stretch;
|
150
|
+
}
|
151
|
+
/**
|
152
|
+
* A pure-flex container will be display: flex.
|
153
|
+
*/
|
154
|
+
.pure-flex {
|
155
|
+
@apply flex;
|
156
|
+
}
|
157
|
+
/**
|
158
|
+
* And its immediate children will have zero padding and margin.
|
159
|
+
*/
|
160
|
+
.pure-flex > * {
|
161
|
+
@apply m-0 p-0;
|
162
|
+
}
|
163
|
+
/*
|
164
|
+
* A flex container centered along both axes.
|
165
|
+
*/
|
166
|
+
.flex-center {
|
167
|
+
@apply flex justify-center items-center;
|
168
|
+
}
|
169
|
+
/**
|
170
|
+
* Center flex and text.
|
171
|
+
*/
|
172
|
+
.center {
|
173
|
+
@apply flex-center text-center;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
/* CONTENT */
|
178
|
+
@layer base {
|
179
|
+
code {}
|
180
|
+
|
181
|
+
main {
|
182
|
+
@apply p-8 flex-col filled flex-center;
|
183
|
+
}
|
184
|
+
|
185
|
+
header {
|
186
|
+
z-index: 9999;
|
187
|
+
}
|
188
|
+
|
189
|
+
footer {
|
190
|
+
@apply flex-center py-4 border-t-2 border-gray-200;
|
191
|
+
}
|
192
|
+
|
193
|
+
article {
|
194
|
+
@apply font-size-base serif mx-auto;
|
195
|
+
@apply max-w-screen-sm lg:max-w-screen-lg 2xl:max-w-screen-2xl 4xl:max-w-screen-4xl;
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
/* FORMS */
|
200
|
+
@layer base {
|
201
|
+
button, .button {
|
202
|
+
text-decoration: none !important;
|
203
|
+
@apply cursor-pointer;
|
204
|
+
@apply pure-flex flex-center;
|
205
|
+
@apply px-8 py-4;
|
206
|
+
@apply rounded-lg border-2;
|
207
|
+
@apply bg-blue-500 text-white font-bold;
|
208
|
+
}
|
209
|
+
|
210
|
+
label {
|
211
|
+
@apply p-4 font-light;
|
212
|
+
}
|
213
|
+
|
214
|
+
input {
|
215
|
+
@apply border-2 border-gray-300 rounded-lg;
|
216
|
+
@apply p-2;
|
217
|
+
}
|
218
|
+
|
219
|
+
select {
|
220
|
+
@apply bg-white;
|
221
|
+
@apply border-2 border-gray-300 rounded-lg;
|
222
|
+
@apply p-2;
|
223
|
+
}
|
224
|
+
|
225
|
+
/* Buttons already signal that the user can interact by touching. */
|
226
|
+
button, .button {
|
227
|
+
text-decoration: none !important;
|
228
|
+
@apply cursor-pointer;
|
229
|
+
@apply pure-flex flex-center;
|
230
|
+
@apply px-8 py-4;
|
231
|
+
@apply rounded-lg border-2;
|
232
|
+
@apply bg-blue-500 text-white font-bold;
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
/* TABLES */
|
237
|
+
@layer base {
|
238
|
+
table {
|
239
|
+
@apply mx-auto w-full;
|
240
|
+
}
|
241
|
+
|
242
|
+
table tr, table tr div {
|
243
|
+
@apply truncate;
|
244
|
+
}
|
245
|
+
|
246
|
+
table tr:nth-child(even) {
|
247
|
+
/* @apply bg-gray-400; */
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
@import './elements/index.css';
|
252
|
+
@import './viewport/index.css';
|
253
|
+
@import './custom/index.css';
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/*
|
2
|
+
* Ensure the page fills the viewport. Prevent purgecss from removing this
|
3
|
+
* styling, which it likes to do for the #__next selector.
|
4
|
+
*/
|
5
|
+
/* purgecss start ignore */
|
6
|
+
html, body, #__next, #root, main {
|
7
|
+
/* Border-box, no padding. */
|
8
|
+
@apply m-0 p-0 box-border;
|
9
|
+
/* Fill screen, flex column, stretch items. */
|
10
|
+
@apply min-h-screen flex-col;
|
11
|
+
}
|
12
|
+
|
13
|
+
html,
|
14
|
+
body {
|
15
|
+
background: #fafafa;
|
16
|
+
|
17
|
+
/* font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
18
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
19
|
+
sans-serif; */
|
20
|
+
-webkit-font-smoothing: antialiased;
|
21
|
+
-moz-osx-font-smoothing: grayscale;
|
22
|
+
/* background-color: #90d5ec; */
|
23
|
+
/* background-image: linear-gradient(320deg, #fec3c5 20%, #d1ebf6 80%); */
|
24
|
+
}
|
25
|
+
|
26
|
+
/* purgecss end ignore */
|
@@ -0,0 +1 @@
|
|
1
|
+
export const PRODUCTION = process.env.NODE_ENV === 'production';
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module.exports = {
|
2
|
+
content: ["src/**/*.{js,ts,jsx,tsx}"],
|
3
|
+
theme: {
|
4
|
+
extend: {
|
5
|
+
screens: {
|
6
|
+
"3xl": "1920px",
|
7
|
+
"4xl": "3840px",
|
8
|
+
},
|
9
|
+
backgroundImage: {
|
10
|
+
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))"
|
11
|
+
},
|
12
|
+
border : [ "hover"],
|
13
|
+
|
14
|
+
|
15
|
+
},
|
16
|
+
},
|
17
|
+
variants: {
|
18
|
+
extend: {},
|
19
|
+
},
|
20
|
+
plugins: [],
|
21
|
+
};
|