@inglorious/ssx 1.3.0 → 1.3.2

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/README.md CHANGED
@@ -52,13 +52,13 @@ npm install @inglorious/ssx @inglorious/web
52
52
 
53
53
  ### Create Your First Site
54
54
 
55
- <!-- ```bash
56
- npx @inglorious/create-app my-site --template ssx
55
+ ```bash
56
+ npx @inglorious/create-app my-site --template ssx-js
57
57
  cd my-site
58
58
  npm run dev
59
59
  ```
60
60
 
61
- Or manually: -->
61
+ Or manually:
62
62
 
63
63
  ### Create Your First Site (TypeScript)
64
64
 
@@ -224,7 +224,7 @@ export const about = {
224
224
  ```
225
225
 
226
226
  ```javascript
227
- // src/entities.js
227
+ // src/store/entities.js
228
228
  export const entities = {
229
229
  about: {
230
230
  type: "about",
@@ -408,7 +408,7 @@ SSX provides a simple CLI for building and developing:
408
408
  Builds your static site:
409
409
 
410
410
  ```bash
411
- ssx build [options]
411
+ pnpm ssx build [options]
412
412
 
413
413
  Options:
414
414
  -c, --config <file> Config file (default: "site.config.js")
@@ -418,12 +418,20 @@ Options:
418
418
  -f, --force Force clean build, ignore cache
419
419
  ```
420
420
 
421
+ ### `preview`
422
+
423
+ Serves the built static site on port 3000 through the `serve` NPM package.
424
+
425
+ ```bash
426
+ pnpm preview
427
+ ```
428
+
421
429
  ### `ssx dev`
422
430
 
423
- Starts development server with hot reload:
431
+ Starts the Vite development server on port 3000 with hot reload:
424
432
 
425
433
  ```bash
426
- ssx dev [options]
434
+ pnpm ssx dev [options]
427
435
 
428
436
  Options:
429
437
  -c, --config <file> Config file (default: "site.config.js")
@@ -431,18 +439,6 @@ Options:
431
439
  -p, --port <port> Dev server port (default: 3000)
432
440
  ```
433
441
 
434
- ### Package.json Scripts
435
-
436
- ```json
437
- {
438
- "scripts": {
439
- "dev": "ssx dev",
440
- "build": "ssx build",
441
- "preview": "pnpm dlx serve dist"
442
- }
443
- }
444
- ```
445
-
446
442
  ---
447
443
 
448
444
  ## Project Structure
@@ -456,7 +452,8 @@ my-site/
456
452
  │ │ └── posts/
457
453
  │ │ ├── index.js # /posts
458
454
  │ │ └── _id.js # /posts/:id
459
- │ ├── entities.js # Entity definitions
455
+ │ ├── store/ # Store configuration
456
+ │ │ └── entities.js # Entity definitions
460
457
  │ └── types/ # Custom entity types (optional)
461
458
  ├── dist/ # Build output
462
459
  ├── package.json
@@ -575,7 +572,7 @@ export const metadata = {
575
572
  Register it in your router:
576
573
 
577
574
  ```javascript
578
- // src/entities.js
575
+ // src/store/entities.js
579
576
  import { setRoutes } from "@inglorious/web/router"
580
577
 
581
578
  setRoutes({
package/bin/ssx.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { existsSync } from "node:fs"
2
3
  import { readFile } from "node:fs/promises"
3
4
  import path from "node:path"
4
5
  import { fileURLToPath } from "node:url"
@@ -31,10 +32,12 @@ program
31
32
  .option("-p, --port <port>", "dev server port", 3000)
32
33
  .action(async (options) => {
33
34
  const cwd = process.cwd()
35
+ const config = resolveConfigFile(options.config)
34
36
 
35
37
  try {
36
38
  await dev({
37
39
  ...options,
40
+ config,
38
41
  rootDir: path.resolve(cwd, options.root),
39
42
  port: Number(options.port),
40
43
  })
@@ -54,10 +57,12 @@ program
54
57
  .option("-f, --force", "force clean build (ignore cache)", false)
55
58
  .action(async (options) => {
56
59
  const cwd = process.cwd()
60
+ const config = resolveConfigFile(options.config)
57
61
 
58
62
  try {
59
63
  await build({
60
64
  ...options,
65
+ config,
61
66
  rootDir: path.resolve(cwd, options.root),
62
67
  outDir: path.resolve(cwd, options.out),
63
68
  incremental: options.incremental, // Enabled by default
@@ -76,3 +81,15 @@ program
76
81
  })
77
82
 
78
83
  program.parse()
84
+
85
+ function resolveConfigFile(configFile) {
86
+ if (configFile === "site.config.js") {
87
+ const jsPath = path.resolve(process.cwd(), "site.config.js")
88
+ const tsPath = path.resolve(process.cwd(), "site.config.ts")
89
+
90
+ if (!existsSync(jsPath) && existsSync(tsPath)) {
91
+ return "site.config.ts"
92
+ }
93
+ }
94
+ return configFile
95
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/ssx",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Server-Side-X. Xecution? Xperience? Who knows.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -44,14 +44,15 @@
44
44
  "fast-xml-parser": "^5.3.3",
45
45
  "glob": "^13.0.0",
46
46
  "rollup-plugin-minify-template-literals": "^1.1.7",
47
+ "sharp": "^0.34.5",
48
+ "svgo": "^4.0.0",
47
49
  "vite": "^7.1.3",
48
- "@inglorious/web": "4.0.1"
50
+ "vite-plugin-image-optimizer": "^2.0.3",
51
+ "@inglorious/web": "4.0.2"
49
52
  },
50
53
  "devDependencies": {
51
54
  "prettier": "^3.6.2",
52
- "sharp": "^0.34.5",
53
- "svgo": "^4.0.0",
54
- "vite-plugin-image-optimizer": "^2.0.3",
55
+ "serve": "^14.2.1",
55
56
  "vitest": "^1.6.1",
56
57
  "@inglorious/eslint-config": "1.1.1"
57
58
  },
@@ -65,6 +66,6 @@
65
66
  "test": "vitest run",
66
67
  "dev": "node ./bin/ssx.js dev -r ./src/__fixtures__",
67
68
  "build": "node ./bin/ssx.js build -r ./src/__fixtures__",
68
- "preview": "pnpm dlx serve dist"
69
+ "preview": "serve dist"
69
70
  }
70
71
  }
@@ -57,7 +57,7 @@ export async function hashFile(filePath) {
57
57
  * @returns {Promise<string|null>} Hash of entities.js.
58
58
  */
59
59
  export async function hashEntities(rootDir) {
60
- const entitiesPath = path.join(rootDir, "entities.js")
60
+ const entitiesPath = path.join(rootDir, "store", "entities.js")
61
61
  return await hashFile(entitiesPath)
62
62
  }
63
63
 
@@ -32,7 +32,7 @@ export async function generateStore(pages = [], options = {}, loader) {
32
32
 
33
33
  for (const ext of extensions) {
34
34
  try {
35
- const module = await load(path.join(rootDir, `entities.${ext}`))
35
+ const module = await load(path.join(rootDir, "store", `entities.${ext}`))
36
36
  entities = module.entities
37
37
  break
38
38
  } catch {
@@ -68,7 +68,11 @@ describe("generateStore", () => {
68
68
  await generateStore([page], { rootDir: "src" }, loader)
69
69
 
70
70
  expect(loader).toHaveBeenCalledWith(page.filePath)
71
- expect(loader).toHaveBeenCalledWith(path.join("src", "entities.js"))
72
- expect(loader).toHaveBeenCalledWith(path.join("src", "entities.ts"))
71
+ expect(loader).toHaveBeenCalledWith(
72
+ path.join("src", "store", "entities.js"),
73
+ )
74
+ expect(loader).toHaveBeenCalledWith(
75
+ path.join("src", "store", "entities.ts"),
76
+ )
73
77
  })
74
78
  })