|
| 1 | +# CloneIt |
| 2 | + |
| 3 | +Clone the demo site to create a new repoless AEM site with one click. |
| 4 | + |
| 5 | +## What It Does |
| 6 | + |
| 7 | +CloneIt creates a new repoless site by: |
| 8 | + |
| 9 | +1. **Creating DA folder** – Creates the new site folder in DA with a minimal `index.html`. |
| 10 | +2. **Copying DA config** – Fetches repo-level config from the baseline via [DA Config GET](https://opensource.adobe.com/da-admin/#tag/Config/operation/getConfig) and creates it for the new site via [DA Config POST](https://opensource.adobe.com/da-admin/#tag/Config/operation/createConfig). Skipped if baseline has no config. |
| 11 | +3. **Copying DA content** – Recursively copies all files from `cloudadoption/diyfire` to the new site folder, skipping `drafts` and `demo-docs`. Uses the [DA List API](https://admin.da.live/list) to discover all files, then the [DA Copy API](https://opensource.adobe.com/da-admin/#tag/Copy) per file (the Copy API does not recurse into folders). If copy fails, falls back to updating the minimal `index.html`. |
| 12 | +4. **Creating the AEM site config** – Fetches the baseline diyfire configuration from the [AEM Admin API](https://www.aem.live/docs/admin.html#tag/siteConfig/operation/createSiteSite), copies only code, sidekick, and headers, sets content to the new DA URL, and creates the site via `PUT /config/{org}/sites/{site}.json` |
| 13 | +5. **Copying query index config** – Fetches the baseline `query.yaml` and creates it for the new site. Skipped if the baseline has no index config. |
| 14 | + |
| 15 | +The new site shares the same codebase (diyfire) and uses `https://content.da.live/cloudadoption/{sitename}/` as its content source. |
| 16 | + |
| 17 | +## How to Use |
| 18 | + |
| 19 | +1. Open the app from the AEM Sidekick (CloneIt button) or navigate to `/tools/cloneit/cloneit.html` |
| 20 | +2. **Authentication** – The app must be opened from a DA context (e.g. da.live) to obtain the bearer token for API calls |
| 21 | +3. Enter a **site name** (lowercase, numbers and hyphens only, max 50 chars, e.g. `my-new-site`). Reserved names like `admin`, `api`, `config` are blocked. |
| 22 | +4. Click **Clone Site** |
| 23 | +5. Access your new site at `https://main--{sitename}--cloudadoption.aem.page` |
| 24 | +6. **Bulk Preview/Publish** (optional) – After a successful clone, click **Bulk Preview/Publish** to copy all content URLs to your clipboard. A modal guides you to the [DA Bulk app](https://da.live/apps/bulk), where you paste the URLs and run preview or publish as needed. |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## App Structure (for maintainers) |
| 29 | + |
| 30 | +This section describes where things live so the app is easy to follow and change. |
| 31 | + |
| 32 | +### File layout |
| 33 | + |
| 34 | +All CloneIt files live under the project’s `tools/cloneit/` folder: |
| 35 | + |
| 36 | +| File | Role | |
| 37 | +|------|------| |
| 38 | +| `cloneit.html` | Single-page UI: header, config card, progress section, result section, bulk modal, help modal, toast | |
| 39 | +| `cloneit.js` | All app logic: constants, validation, API calls, clone flow, bulk flow, event wiring, init | |
| 40 | +| `cloneit.css` | All styles (no preprocessor). Scoped by section/component class names. | |
| 41 | +| `README.md` | This documentation | |
| 42 | + |
| 43 | +### HTML structure (`cloneit.html`) |
| 44 | + |
| 45 | +- **Header** – Title, subtitle, Help button |
| 46 | +- **Config card** – Site name input, live preview URL, Clone button |
| 47 | +- **Progress section** – Shown during clone: phase, progress bar, status text, file list |
| 48 | +- **Result section** – Success card (summary list, Bulk Preview/Publish button, Preview/DA/Code links) or error card |
| 49 | +- **Bulk modal** – “URLs copied” message and “Open DA Bulk app” button (no in-app bulk API) |
| 50 | +- **Help modal** – What CloneIt does, naming rules, after-clone steps, bulk flow |
| 51 | +- **Toast** – Temporary success/error/info messages |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## APIs Used |
| 56 | + |
| 57 | +| API | Endpoint | Purpose | |
| 58 | +|-----|----------|---------| |
| 59 | +| DA Admin | `GET /config/cloudadoption/diyfire/` | Fetch baseline repo config | |
| 60 | +| DA Admin | `POST /config/cloudadoption/{site}/` | Create config for new site | |
| 61 | +| DA Admin | `GET /list/cloudadoption/diyfire/{path}` | Discover all files recursively | |
| 62 | +| DA Admin | `POST /copy/cloudadoption/diyfire/{path}` | Copy each file to new site folder | |
| 63 | +| DA Admin | `POST /source/cloudadoption/{site}/index.html` | Fallback: create minimal content if copy fails | |
| 64 | +| AEM Admin | `GET /config/cloudadoption/sites/diyfire.json` | Fetch baseline config | |
| 65 | +| AEM Admin | `PUT /config/cloudadoption/sites/{site}.json` | Create repoless site | |
| 66 | +| AEM Admin | `GET /config/cloudadoption/sites/diyfire/content/query.yaml` | Fetch baseline index config | |
| 67 | +| AEM Admin | `PUT /config/cloudadoption/sites/{site}/content/query.yaml` | Create index config for new site | |
| 68 | + |
| 69 | +## Authentication |
| 70 | + |
| 71 | +Uses the [DA SDK](https://da.live/nx/utils/sdk.js) to obtain a bearer token. The same token works for both AEM Admin API and DA Admin API when the user is authenticated in the DA context. |
| 72 | + |
| 73 | +## References |
| 74 | + |
| 75 | +- [Repoless documentation](https://www.aem.live/docs/repoless) |
| 76 | +- [AEM Admin API – Create Site](https://www.aem.live/docs/admin.html#tag/siteConfig/operation/createSiteSite) |
| 77 | +- [AEM Admin API – Create Index Config](https://www.aem.live/docs/admin.html#tag/indexConfig/operation/createIndexConfig) |
| 78 | +- [DA Admin API – Create Source](https://opensource.adobe.com/da-admin/#tag/Source/operation/createSource) |
| 79 | +- [DA Admin API – Get Config](https://opensource.adobe.com/da-admin/#tag/Config/operation/getConfig) |
| 80 | +- [DA Admin API – Create Config](https://opensource.adobe.com/da-admin/#tag/Config/operation/createConfig) |
0 commit comments