codepen-demokit 1.0.0 → 1.1.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/README.md CHANGED
@@ -7,9 +7,10 @@ Powered by [CodePen Commander](https://www.npmjs.com/package/codepen-commander)
7
7
  ## Features
8
8
 
9
9
  - **Core CodePen 2.0 Sync**: Built-in bulk `sync`, `push`, `pull`, and `delete` (with `--keep-info`) commands scoped to all of `src/`, a topic group/subgroup, or a single demo—backed by CodePen Commander (`codepen-commander` is included as a direct dependency).
10
- - **Auto-Generated Demo Index**: Recursively scans `src/` subfolders for demos (standalone, grouped, and arbitrarily nested subgroups), reading each demo's `<title>`, optional `<meta name="description">`, and `.cdpn.json` CodePen link.
10
+ - **Auto-Generated Demo Index**: Recursively scans `src/` for demo folders containing a `.cdpn.json` or `index.html` file (standalone, grouped, and arbitrarily nested subgroups), reading each demo's title/description from `index.html` and/or `.cdpn.json` along with its CodePen link.
11
11
  - **Updatable Index UI Shell**: Ships a modern, accessible light/dark index page (`shell/`) that updates automatically when you upgrade `codepen-demokit`—and can be customized via `config.json` or overridden selectively in `src/`.
12
12
  - **Zero-Config Local Dev Server**: `start` builds `dist/demos.json`, watches `src/` to rebuild it on the fly, serves demos directly from `src/`, and lets you preview a single demo subfolder as root.
13
+ - **CodePen Blocks Support (`classic` & `packages`)**: Inspects `.codepen/pen.config.json` on the fly in `start` (and during `build`) to assemble `*.pen.html` + `.codepen/classic.config.json` for converted Classic Pens, inject `<script type="importmap">` from `package.json` for `packages`-enabled Pens, and render a helpful error page with links back to the homepage and CodePen for Pens using unsupported blocks—with zero build step during local dev.
13
14
  - **Static Deployment Ready**: `build` outputs a self-contained `dist/` folder ready for GitHub Pages, Netlify, Cloudflare Pages, Vercel, or any static host (stripping `.cdpn.json` and dotfiles automatically).
14
15
  - **Separate Git Repos**: Your demos live in their own clean Git repo and depend on `codepen-demokit` via `package.json`.
15
16
 
@@ -29,10 +30,9 @@ The interactive initializer prompts for:
29
30
 
30
31
  1. **Project name** (default: `"My CodePen Demos"`)
31
32
  2. **Directory** (defaults to the slugified project name, e.g. `my-codepen-demos`)
32
- 3. **CodePen username** (optional, stored in `config.json`)
33
- 4. **Default Pen visibility** (`Private`, `Public`, `Protected`, or `Collaborators`; default: `Private`)
33
+ 3. **CodePen details** (optional — if you choose to set them up now: **CodePen username** and **Default Pen visibility**: `Private`, `Public`, `Protected`, or `Collaborators`; default: `Private`)
34
34
 
35
- After creating the files, if you entered a CodePen username that isn't configured in `~/.cdpn` yet, `init` offers to run `cdpn auth login <username>` right away.
35
+ After creating the files, if you entered a CodePen username that isn't authenticated in `~/.cdpn` yet, `init` lets you know and offers to set up CodePen authentication right away.
36
36
 
37
37
  Then enter the created folder, initialize Git, and install dependencies:
38
38
 
@@ -82,7 +82,7 @@ npx cdpn auth status
82
82
 
83
83
  ### 3. Add demos under `src/` and start developing
84
84
 
85
- Each demo lives in its own self-contained `kebab-case` folder inside `src/`—either standalone, inside a topic group, or inside nested subgroups:
85
+ Each demo lives in its own self-contained `kebab-case` folder inside `src/` containing a `.cdpn.json` or `index.html` file—either standalone, inside a topic group, or inside nested subgroups:
86
86
 
87
87
  ```text
88
88
  src/
@@ -138,6 +138,10 @@ npm run cdpn:delete
138
138
  # Clone an existing CodePen Pen into src/ (forwards arguments & flags to `cdpn clone`)
139
139
  npm run cdpn:clone -- https://codepen.io/username/pen/slug
140
140
  npm run cdpn:clone -- https://codepen.io/username/pen/slug group/my-demo
141
+
142
+ # Scaffold a brand-new CodePen 2.0 Pen in src/ (forwards arguments & flags to `cdpn new`)
143
+ npm run cdpn:new
144
+ npm run cdpn:new -- group/my-demo
141
145
  ```
142
146
 
143
147
  ### Scoping & Flags
@@ -158,11 +162,12 @@ npm run cdpn:delete -- view-transitions/same-document --dry-run
158
162
  # Force-pull all linked demos (overwrites local changes and refreshes .cdpn.json)
159
163
  npm run cdpn:pull -- --force
160
164
 
161
- # Forward any `cdpn clone` options (such as --force, --json, or --help)
165
+ # Forward any `cdpn clone` or `cdpn new` options (such as --force, --title, --access, --json, or --help)
162
166
  npm run cdpn:clone -- --force https://codepen.io/username/pen/slug my-demo
167
+ npm run cdpn:new -- -t "My Demo" --access Private group/my-demo
163
168
  ```
164
169
 
165
- `cdpn:clone` runs `cdpn clone` inside `src/` using your `codepen.user` profile from `config.json` (when configured) and forwards all arguments and options directly to CodePen Commander.
170
+ `cdpn:clone` and `cdpn:new` run `cdpn clone` / `cdpn new` inside `src/` using your `codepen.user` profile from `config.json` (when configured) and forward all arguments and options directly to CodePen Commander.
166
171
 
167
172
  Each synced demo stores non-secret sync metadata in `.cdpn.json` (plus optional `.codepen/pen.config.json`). Keep `.cdpn.json` committed in your demos repo so sync state persists across machines. Add an optional `.cdpnignore` file inside a demo folder to exclude local-only files from syncing.
168
173
 
@@ -216,6 +221,7 @@ You can invoke the CLI directly via `npx codepen-demokit <command>` or through y
216
221
  | `codepen-demokit build [--watch]` | Build the static deployable site into `dist/` (optionally watching `src/` and `config.json`). |
217
222
  | `codepen-demokit cdpn <sync\|pull\|push\|delete> [folder] [--dry-run] [--force]` | Bulk sync demos with CodePen via CodePen Commander. |
218
223
  | `codepen-demokit cdpn clone [options] <url> [folder]` | Clone a CodePen Pen into `src/` via `cdpn clone` (passing through arguments & options). |
224
+ | `codepen-demokit cdpn new [options] [folder]` | Scaffold a new CodePen Pen in `src/` via `cdpn new` (passing through arguments & options). |
219
225
 
220
226
  ---
221
227
 
package/bin/cli.mjs CHANGED
@@ -23,6 +23,7 @@ Commands:
23
23
  build [--watch] Build static deployable site into dist/
24
24
  cdpn <sync|pull|push|delete> [folder] [flags] Bulk sync demos with CodePen via CodePen Commander
25
25
  cdpn clone [options] <url> [folder] Clone a CodePen Pen into src/ via CodePen Commander
26
+ cdpn new [options] [folder] Scaffold a new CodePen Pen in src/ via CodePen Commander
26
27
 
27
28
  Options:
28
29
  -h, --help Show this help message
@@ -146,7 +147,7 @@ try {
146
147
  }
147
148
  } catch (error) {
148
149
  if (error instanceof InitCancelledError) {
149
- console.error('Init cancelled.');
150
+ console.error('\nInit cancelled.');
150
151
  process.exit(130);
151
152
  }
152
153
  console.error(`Error: ${error.message}`);