@quincarter/create-lit-app 1.1.7 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-lit-app.js +2 -2
- package/bin/create-lit-app.ts +2 -2
- package/create-app-shell.sh +76 -44
- package/man/create-lit-app.1 +1 -1
- package/package.json +40 -34
package/bin/create-lit-app.js
CHANGED
|
@@ -9,9 +9,9 @@ const __dirname = dirname(__filename);
|
|
|
9
9
|
const scriptPath = join(__dirname, "..", "create-app-shell.sh");
|
|
10
10
|
|
|
11
11
|
const child = spawn("bash", [scriptPath, ...process.argv.slice(2)], {
|
|
12
|
-
|
|
12
|
+
stdio: "inherit",
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
child.on("exit", (code) => {
|
|
16
|
-
|
|
16
|
+
process.exit(code ?? 0);
|
|
17
17
|
});
|
package/bin/create-lit-app.ts
CHANGED
|
@@ -9,9 +9,9 @@ const __dirname = dirname(__filename);
|
|
|
9
9
|
const scriptPath = join(__dirname, "..", "create-app-shell.sh");
|
|
10
10
|
|
|
11
11
|
const child = spawn("bash", [scriptPath, ...process.argv.slice(2)], {
|
|
12
|
-
|
|
12
|
+
stdio: "inherit",
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
child.on("exit", (code) => {
|
|
16
|
-
|
|
16
|
+
process.exit(code ?? 0);
|
|
17
17
|
});
|
package/create-app-shell.sh
CHANGED
|
@@ -99,7 +99,7 @@ parse_args() {
|
|
|
99
99
|
--no-install) RUN_INSTALL=false ;;
|
|
100
100
|
-y|--yes) NON_INTERACTIVE=true ;;
|
|
101
101
|
-v|--version)
|
|
102
|
-
echo "@quincarter/create-lit-app v1.0
|
|
102
|
+
echo "@quincarter/create-lit-app v1.3.0"
|
|
103
103
|
exit 0
|
|
104
104
|
;;
|
|
105
105
|
--help|-h)
|
|
@@ -140,6 +140,7 @@ parse_args() {
|
|
|
140
140
|
exit 0
|
|
141
141
|
;;
|
|
142
142
|
-*)
|
|
143
|
+
log_warn "Unknown option ignored: $arg"
|
|
143
144
|
;;
|
|
144
145
|
*)
|
|
145
146
|
if [ -z "$APP_NAME" ]; then
|
|
@@ -506,6 +507,19 @@ if [ "$ENABLE_TODOS" = true ]; then
|
|
|
506
507
|
ENABLE_SIGNALS=true
|
|
507
508
|
fi
|
|
508
509
|
|
|
510
|
+
# The MFE loader is handed to views through @lit/context, so the package and
|
|
511
|
+
# the loader context are needed even when the Context feature itself is off.
|
|
512
|
+
USE_LIT_CONTEXT=false
|
|
513
|
+
if [ "$ENABLE_CONTEXT" = true ] || [ "$ENABLE_MFE_LOADER" = true ]; then
|
|
514
|
+
USE_LIT_CONTEXT=true
|
|
515
|
+
fi
|
|
516
|
+
|
|
517
|
+
# APP_NAME becomes both the directory and the npm package name
|
|
518
|
+
if [[ ! "$APP_NAME" =~ ^[a-z0-9][a-z0-9._-]*$ ]]; then
|
|
519
|
+
log_error "Invalid app name '$APP_NAME' (use lowercase letters, digits, '.', '_' and '-')."
|
|
520
|
+
exit 1
|
|
521
|
+
fi
|
|
522
|
+
|
|
509
523
|
TARGET_DIR="$(pwd)/$APP_NAME"
|
|
510
524
|
|
|
511
525
|
if [ -d "$TARGET_DIR" ]; then
|
|
@@ -528,7 +542,7 @@ if [ "$ENABLE_ROUTER" = true ]; then
|
|
|
528
542
|
\"@lit-labs/router\": \"^0.1.4\",
|
|
529
543
|
\"urlpattern-polyfill\": \"^10.1.0\""
|
|
530
544
|
fi
|
|
531
|
-
if [ "$
|
|
545
|
+
if [ "$USE_LIT_CONTEXT" = true ]; then
|
|
532
546
|
DEPS="$DEPS,
|
|
533
547
|
\"@lit/context\": \"^1.1.6\""
|
|
534
548
|
fi
|
|
@@ -542,7 +556,7 @@ if [ "$ENABLE_CHARTS" = true ]; then
|
|
|
542
556
|
\"chart.js\": \"^4.5.1\",
|
|
543
557
|
\"chartjs-adapter-luxon\": \"^1.3.1\",
|
|
544
558
|
\"luxon\": \"^3.7.2\",
|
|
545
|
-
\"@kurkle/color\": \"^0.4
|
|
559
|
+
\"@kurkle/color\": \"^0.6.4\""
|
|
546
560
|
fi
|
|
547
561
|
|
|
548
562
|
cat <<EOF > package.json
|
|
@@ -554,20 +568,25 @@ cat <<EOF > package.json
|
|
|
554
568
|
"scripts": {
|
|
555
569
|
"start": "vite",
|
|
556
570
|
"build": "tsc && vite build",
|
|
557
|
-
"preview": "
|
|
558
|
-
"test": "vitest run"
|
|
571
|
+
"preview": "tsc && vite build && vite preview",
|
|
572
|
+
"test": "vitest run",
|
|
573
|
+
"fmt": "oxfmt",
|
|
574
|
+
"fmt:check": "oxfmt --check",
|
|
575
|
+
"lint": "oxlint",
|
|
576
|
+
"lint:fix": "oxlint --fix"
|
|
559
577
|
},
|
|
560
578
|
"dependencies": {
|
|
561
579
|
$DEPS
|
|
562
580
|
},
|
|
563
581
|
"devDependencies": {
|
|
564
|
-
"@
|
|
565
|
-
"@types/luxon": "^3.7.5",
|
|
582
|
+
"@types/luxon": "^3.7.6",
|
|
566
583
|
"@types/mocha": "^10.0.10",
|
|
584
|
+
"oxfmt": "^0.72.0",
|
|
585
|
+
"oxlint": "^1.87.0",
|
|
567
586
|
"typescript": "^7.0.2",
|
|
568
|
-
"vite": "^8.
|
|
569
|
-
"vite-plugin-pwa": "^
|
|
570
|
-
"vitest": "^
|
|
587
|
+
"vite": "^8.3.2",
|
|
588
|
+
"vite-plugin-pwa": "^2.0.0",
|
|
589
|
+
"vitest": "^5.0.3"
|
|
571
590
|
}
|
|
572
591
|
}
|
|
573
592
|
EOF
|
|
@@ -575,7 +594,7 @@ EOF
|
|
|
575
594
|
# ------------------------------------------------------------------------------
|
|
576
595
|
# Generate Configuration Files
|
|
577
596
|
# ------------------------------------------------------------------------------
|
|
578
|
-
log_info "Generating configuration files (tsconfig.json, vite.config.ts
|
|
597
|
+
log_info "Generating configuration files (tsconfig.json, vite.config.ts)..."
|
|
579
598
|
|
|
580
599
|
cat <<'EOF' > tsconfig.json
|
|
581
600
|
{
|
|
@@ -610,29 +629,6 @@ export default defineConfig({
|
|
|
610
629
|
});
|
|
611
630
|
EOF
|
|
612
631
|
|
|
613
|
-
cat <<'EOF' > biome.json
|
|
614
|
-
{
|
|
615
|
-
"$schema": "https://biomejs.dev/schemas/2.5.10/schema.json",
|
|
616
|
-
"assist": {
|
|
617
|
-
"actions": {
|
|
618
|
-
"source": {
|
|
619
|
-
"organizeImports": "on"
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
},
|
|
623
|
-
"linter": {
|
|
624
|
-
"enabled": true,
|
|
625
|
-
"rules": {
|
|
626
|
-
"preset": "recommended"
|
|
627
|
-
}
|
|
628
|
-
},
|
|
629
|
-
"formatter": {
|
|
630
|
-
"enabled": true,
|
|
631
|
-
"indentStyle": "tab"
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
EOF
|
|
635
|
-
|
|
636
632
|
cat <<'EOF' > .gitignore
|
|
637
633
|
node_modules
|
|
638
634
|
dist
|
|
@@ -991,6 +987,8 @@ import { createContext } from "@lit/context";
|
|
|
991
987
|
import type { NavItem } from "../interfaces/navigation.interface";
|
|
992
988
|
export const NavigationContext = createContext<NavItem[]>("navContext");
|
|
993
989
|
EOF
|
|
990
|
+
fi
|
|
991
|
+
if [ "$USE_LIT_CONTEXT" = true ]; then
|
|
994
992
|
cat <<'EOF' > src/shared/contexts/mfe-loader.context.ts
|
|
995
993
|
import { createContext } from "@lit/context";
|
|
996
994
|
import type { MfeLoader } from "../utilities/mfe-loader.utility";
|
|
@@ -1264,7 +1262,11 @@ import { property } from "lit/decorators.js";
|
|
|
1264
1262
|
import { withBase } from "../../shared/configuration/base-path";
|
|
1265
1263
|
import type { NavItem } from "../../shared/interfaces/navigation.interface";
|
|
1266
1264
|
import { AppShellHeaderStyles } from "./app-shell-header.styles";
|
|
1267
|
-
|
|
1265
|
+
EOF
|
|
1266
|
+
if [ "$ENABLE_THEME_SWITCHER" = true ]; then
|
|
1267
|
+
echo 'import "../theme-switcher/theme-switcher";' >> src/components/header/AppShellHeader.ts
|
|
1268
|
+
fi
|
|
1269
|
+
cat <<'EOF' >> src/components/header/AppShellHeader.ts
|
|
1268
1270
|
|
|
1269
1271
|
export class AppShellHeader extends LitElement {
|
|
1270
1272
|
@property({ attribute: "routes", type: Array })
|
|
@@ -1814,17 +1816,27 @@ export const AppShellStyles = css`
|
|
|
1814
1816
|
`;
|
|
1815
1817
|
EOF
|
|
1816
1818
|
|
|
1819
|
+
# @state is only used by the router/header nav list and the MFE loader
|
|
1820
|
+
DECORATORS="customElement, property"
|
|
1821
|
+
if [ "$ENABLE_ROUTER" = true ] || [ "$ENABLE_HEADER" = true ] || [ "$ENABLE_MFE_LOADER" = true ]; then
|
|
1822
|
+
DECORATORS="$DECORATORS, state"
|
|
1823
|
+
fi
|
|
1824
|
+
|
|
1817
1825
|
IMPORTS="import { type HTMLTemplateResult, html, LitElement } from 'lit';
|
|
1818
|
-
import {
|
|
1826
|
+
import { $DECORATORS } from 'lit/decorators.js';
|
|
1819
1827
|
import { AppShellStyles } from './app-shell.styles';
|
|
1820
1828
|
import type { NavItem } from './shared/interfaces/navigation.interface';
|
|
1821
1829
|
import \"./shared/internal-views/404-not-found/page-not-found\";
|
|
1822
1830
|
import \"./shared/internal-views/no-access/no-access\";
|
|
1823
1831
|
import \"./shared/internal-views/under-construction/under-construction\";"
|
|
1824
1832
|
|
|
1833
|
+
if [ "$USE_LIT_CONTEXT" = true ]; then
|
|
1834
|
+
IMPORTS="$IMPORTS
|
|
1835
|
+
import { provide } from '@lit/context';"
|
|
1836
|
+
fi
|
|
1837
|
+
|
|
1825
1838
|
if [ "$ENABLE_CONTEXT" = true ]; then
|
|
1826
1839
|
IMPORTS="$IMPORTS
|
|
1827
|
-
import { provide } from '@lit/context';
|
|
1828
1840
|
import { AccessesContext } from './shared/contexts/accesses.context';
|
|
1829
1841
|
import { NavigationContext } from './shared/contexts/navigation.context';"
|
|
1830
1842
|
fi
|
|
@@ -1885,10 +1897,16 @@ cat <<EOF >> src/app-shell.ts
|
|
|
1885
1897
|
EOF
|
|
1886
1898
|
fi
|
|
1887
1899
|
|
|
1888
|
-
|
|
1900
|
+
# The header binds to navRoutes, so it exists even without the router
|
|
1901
|
+
if [ "$ENABLE_ROUTER" = true ] || [ "$ENABLE_HEADER" = true ]; then
|
|
1889
1902
|
cat <<EOF >> src/app-shell.ts
|
|
1890
1903
|
@state()
|
|
1891
1904
|
navRoutes: NavItem[] = [] as NavItem[];
|
|
1905
|
+
EOF
|
|
1906
|
+
fi
|
|
1907
|
+
|
|
1908
|
+
if [ "$ENABLE_ROUTER" = true ]; then
|
|
1909
|
+
cat <<EOF >> src/app-shell.ts
|
|
1892
1910
|
|
|
1893
1911
|
@state()
|
|
1894
1912
|
notAllowedRouteList: NavItem[] = [];
|
|
@@ -1907,7 +1925,9 @@ fi
|
|
|
1907
1925
|
|
|
1908
1926
|
if [ "$ENABLE_ROUTER" = true ]; then
|
|
1909
1927
|
cat <<EOF >> src/app-shell.ts
|
|
1910
|
-
private _router = new Router(this, []
|
|
1928
|
+
private _router = new Router(this, [], {
|
|
1929
|
+
fallback: { render: () => html\`<page-not-found></page-not-found>\` },
|
|
1930
|
+
});
|
|
1911
1931
|
EOF
|
|
1912
1932
|
fi
|
|
1913
1933
|
|
|
@@ -2001,8 +2021,12 @@ cat <<EOF >> src/app-shell.ts
|
|
|
2001
2021
|
EOF
|
|
2002
2022
|
|
|
2003
2023
|
if [ "$ENABLE_HEADER" = true ]; then
|
|
2024
|
+
HEADER_ATTRS=""
|
|
2025
|
+
if [ "$ENABLE_THEME_SWITCHER" = true ]; then
|
|
2026
|
+
HEADER_ATTRS=" enable-theme-switcher"
|
|
2027
|
+
fi
|
|
2004
2028
|
cat <<EOF >> src/app-shell.ts
|
|
2005
|
-
<app-shell-header .routes="\${this.navRoutes}"
|
|
2029
|
+
<app-shell-header .routes="\${this.navRoutes}"$HEADER_ATTRS>
|
|
2006
2030
|
<main>
|
|
2007
2031
|
EOF
|
|
2008
2032
|
else
|
|
@@ -2190,7 +2214,7 @@ $(echo -e "$FEATURES")
|
|
|
2190
2214
|
|
|
2191
2215
|
### Prerequisites
|
|
2192
2216
|
|
|
2193
|
-
Node.js
|
|
2217
|
+
Node.js 20.19+ (or 22.12+) and \`$PACKAGE_MANAGER\`.
|
|
2194
2218
|
|
|
2195
2219
|
### Installation
|
|
2196
2220
|
|
|
@@ -2236,7 +2260,8 @@ $TREE
|
|
|
2236
2260
|
|
|
2237
2261
|
## 🎨 Code Style & Tooling
|
|
2238
2262
|
|
|
2239
|
-
- **
|
|
2263
|
+
- **Formatting**: oxfmt (\`$RUN_CMD fmt\` / \`$RUN_CMD fmt:check\`)
|
|
2264
|
+
- **Linting**: oxlint (\`$RUN_CMD lint\` / \`$RUN_CMD lint:fix\`)
|
|
2240
2265
|
- **Type Checking**: TypeScript (\`npx tsc --noEmit\`)
|
|
2241
2266
|
EOF
|
|
2242
2267
|
|
|
@@ -2251,9 +2276,16 @@ if [ "$INIT_GIT" = true ]; then
|
|
|
2251
2276
|
log_success "Git repository initialized."
|
|
2252
2277
|
fi
|
|
2253
2278
|
|
|
2279
|
+
# The templates are not written in oxfmt's style, so format once the
|
|
2280
|
+
# formatter is available to leave the new project passing `fmt:check`.
|
|
2281
|
+
install_deps() {
|
|
2282
|
+
$PACKAGE_MANAGER install
|
|
2283
|
+
$PACKAGE_MANAGER run fmt >/dev/null 2>&1 || log_warn "Could not format the project; run '$PACKAGE_MANAGER run fmt' manually."
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2254
2286
|
if [ "$RUN_INSTALL" = true ]; then
|
|
2255
2287
|
log_info "Installing dependencies with $PACKAGE_MANAGER..."
|
|
2256
|
-
|
|
2288
|
+
install_deps
|
|
2257
2289
|
log_success "Dependencies installed."
|
|
2258
2290
|
fi
|
|
2259
2291
|
|
|
@@ -2270,7 +2302,7 @@ if [ "$NON_INTERACTIVE" = false ]; then
|
|
|
2270
2302
|
cd "$TARGET_DIR" || exit 1
|
|
2271
2303
|
if [ "$RUN_INSTALL" = false ]; then
|
|
2272
2304
|
log_info "Installing dependencies first..."
|
|
2273
|
-
|
|
2305
|
+
install_deps
|
|
2274
2306
|
fi
|
|
2275
2307
|
exec $PACKAGE_MANAGER start
|
|
2276
2308
|
fi
|
package/man/create-lit-app.1
CHANGED
|
@@ -17,7 +17,7 @@ Set the project directory and package name (default: my-app-shell).
|
|
|
17
17
|
Starter template preset: \fBfull\fR | \fBblank\fR | \fBcustom\fR (default: full).
|
|
18
18
|
.TP
|
|
19
19
|
.BR \-\-pm= \fIPM\fR
|
|
20
|
-
Package manager to use: \fByarn\fR | \fBnpm\fR (default: yarn).
|
|
20
|
+
Package manager to use: \fByarn\fR | \fBnpm\fR | \fBpnpm\fR (default: yarn).
|
|
21
21
|
.TP
|
|
22
22
|
.BR \-\-router ", " \-\-no-router
|
|
23
23
|
Enable or disable @lit-labs/router (automatically enables @lit/context).
|
package/package.json
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quincarter/create-lit-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Interactive CLI initializer for Lit Element App Shell architecture",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"create-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"app-shell",
|
|
7
|
+
"cli",
|
|
8
|
+
"create-lit-app",
|
|
9
|
+
"lit",
|
|
10
|
+
"lit-element",
|
|
11
|
+
"scaffold",
|
|
12
|
+
"signals",
|
|
13
|
+
"vite"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Quin Carter",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/quincarter/app-shell-starter.git"
|
|
17
20
|
},
|
|
18
21
|
"man": "./man/create-lit-app.1",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
22
|
+
"bin": {
|
|
23
|
+
"create-app-shell": "./bin/create-lit-app.js",
|
|
24
|
+
"create-lit-app": "./bin/create-lit-app.js"
|
|
21
25
|
},
|
|
22
26
|
"files": [
|
|
23
27
|
"bin/",
|
|
@@ -25,26 +29,28 @@
|
|
|
25
29
|
"man/",
|
|
26
30
|
"README.md"
|
|
27
31
|
],
|
|
32
|
+
"type": "module",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsx scripts/build-cli.ts",
|
|
38
|
+
"fmt": "oxfmt scripts bin package.json tsconfig.json",
|
|
39
|
+
"fmt:check": "oxfmt --check scripts bin package.json tsconfig.json",
|
|
40
|
+
"lint": "oxlint scripts bin",
|
|
41
|
+
"lint:fix": "oxlint --fix scripts bin",
|
|
42
|
+
"prepare": "npm run build",
|
|
43
|
+
"prepublishOnly": "npm run build",
|
|
44
|
+
"changeset": "changeset",
|
|
45
|
+
"version-packages": "changeset version",
|
|
46
|
+
"release": "changeset publish && git push --tags && tsx scripts/sync-releases.ts"
|
|
47
|
+
},
|
|
28
48
|
"devDependencies": {
|
|
29
|
-
"@changesets/cli": "^3.0.
|
|
30
|
-
"@types/node": "^26.
|
|
31
|
-
"
|
|
49
|
+
"@changesets/cli": "^3.0.3",
|
|
50
|
+
"@types/node": "^26.6.4",
|
|
51
|
+
"oxfmt": "^0.72.0",
|
|
52
|
+
"oxlint": "^1.87.0",
|
|
53
|
+
"tsx": "^4.23.15",
|
|
32
54
|
"typescript": "^7.0.2"
|
|
33
|
-
},
|
|
34
|
-
"keywords": [
|
|
35
|
-
"create-lit-app",
|
|
36
|
-
"lit",
|
|
37
|
-
"lit-element",
|
|
38
|
-
"app-shell",
|
|
39
|
-
"signals",
|
|
40
|
-
"vite",
|
|
41
|
-
"scaffold",
|
|
42
|
-
"cli"
|
|
43
|
-
],
|
|
44
|
-
"author": "Quin Carter",
|
|
45
|
-
"license": "MIT",
|
|
46
|
-
"repository": {
|
|
47
|
-
"type": "git",
|
|
48
|
-
"url": "git+https://github.com/quincarter/app-shell-starter.git"
|
|
49
55
|
}
|
|
50
56
|
}
|