Skip to content
This repository was archived by the owner on Sep 18, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> Slice Machine is replaced by the [Prismic CLI](https://prismic.io/docs/cli) and the [Type Builder](https://prismic.io/docs/type-builder). Existing projects are still supported. To move a project, see [Migrate to the Type Builder](https://prismic.io/docs/slice-machine#migrate-to-the-type-builder).
>
> Using an AI agent? Teach it the new way by installing the Prismic skill:
>
> ```bash
> npx skills add --global --yes prismicio/skills
> ```

<p align="center">
<a href="https://slicemachine.dev">
<img src=".github/logo.svg" alt="Slice Machine logo" width="220" />
Expand Down
8 changes: 8 additions & 0 deletions packages/adapter-next/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> Slice Machine is replaced by the [Prismic CLI](https://prismic.io/docs/cli) and the [Type Builder](https://prismic.io/docs/type-builder). Existing projects are still supported. To move a project, see [Migrate to the Type Builder](https://prismic.io/docs/slice-machine#migrate-to-the-type-builder).
>
> Using an AI agent? Teach it the new way by installing the Prismic skill:
>
> ```bash
> npx skills add --global --yes prismicio/skills
> ```

# @slicemachine/adapter-next

[![npm version][npm-version-src]][npm-version-href]
Expand Down
8 changes: 8 additions & 0 deletions packages/adapter-nuxt/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> Slice Machine is replaced by the [Prismic CLI](https://prismic.io/docs/cli) and the [Type Builder](https://prismic.io/docs/type-builder). Existing projects are still supported. To move a project, see [Migrate to the Type Builder](https://prismic.io/docs/slice-machine#migrate-to-the-type-builder).
>
> Using an AI agent? Teach it the new way by installing the Prismic skill:
>
> ```bash
> npx skills add --global --yes prismicio/skills
> ```

# @slicemachine/adapter-nuxt

[![npm version][npm-version-src]][npm-version-href]
Expand Down
8 changes: 8 additions & 0 deletions packages/adapter-nuxt2/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> Slice Machine is replaced by the [Prismic CLI](https://prismic.io/docs/cli) and the [Type Builder](https://prismic.io/docs/type-builder). Existing projects are still supported. To move a project, see [Migrate to the Type Builder](https://prismic.io/docs/slice-machine#migrate-to-the-type-builder).
>
> Using an AI agent? Teach it the new way by installing the Prismic skill:
>
> ```bash
> npx skills add --global --yes prismicio/skills
> ```

# @slicemachine/adapter-nuxt2

[![npm version][npm-version-src]][npm-version-href]
Expand Down
8 changes: 8 additions & 0 deletions packages/adapter-sveltekit/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> Slice Machine is replaced by the [Prismic CLI](https://prismic.io/docs/cli) and the [Type Builder](https://prismic.io/docs/type-builder). Existing projects are still supported. To move a project, see [Migrate to the Type Builder](https://prismic.io/docs/slice-machine#migrate-to-the-type-builder).
>
> Using an AI agent? Teach it the new way by installing the Prismic skill:
>
> ```bash
> npx skills add --global --yes prismicio/skills
> ```

# @slicemachine/adapter-sveltekit

[![npm version][npm-version-src]][npm-version-href]
Expand Down
8 changes: 8 additions & 0 deletions packages/init/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> Slice Machine is replaced by the [Prismic CLI](https://prismic.io/docs/cli) and the [Type Builder](https://prismic.io/docs/type-builder). Existing projects are still supported. To move a project, see [Migrate to the Type Builder](https://prismic.io/docs/slice-machine#migrate-to-the-type-builder).
>
> Using an AI agent? Teach it the new way by installing the Prismic skill:
>
> ```bash
> npx skills add --global --yes prismicio/skills
> ```

# @slicemachine/init

[![npm version][npm-version-src]][npm-version-href]
Expand Down
112 changes: 89 additions & 23 deletions packages/init/bin/slicemachine-init.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,97 @@
#!/usr/bin/env node

import semver from "semver";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
import chalk from "chalk";

const __dirname = dirname(fileURLToPath(import.meta.url));
const pkg = JSON.parse(
readFileSync(join(__dirname, "../package.json"), "utf8"),
);
// Slice Machine is deprecated. Every run says so. Without `--force` the run
// stops here; with it, the original CLI takes over.

const requiredVersion = pkg.engines.node;
import { createRequire } from "node:module";
import { setTimeout } from "node:timers/promises";
import { parseArgs } from "node:util";

if (!requiredVersion) {
throw new Error("Missing engines.node in package.json.");
}
// The manager's ES build has directory imports Node rejects; use CommonJS.
const require = createRequire(import.meta.url);
const { createSliceMachineManager } = require("@slicemachine/manager");
const pkg = require("../package.json");

const { values } = parseArgs({
args: process.argv.slice(2),
options: {
repository: { type: "string", short: "r" },
force: { type: "boolean" },
},
strict: false,
allowPositionals: true,
});
// The previous parser also accepted `-r=<name>`.
const repository =
typeof values.repository === "string"
? values.repository.replace(/^=/, "")
: undefined;
// `--force=true` parses as a string, so accept both spellings.
const forced = values.force === true || values.force === "true";

const prismicInit = repository
? `npx prismic init --repo ${repository}`
: "npx prismic init";
const slicemachineInit = repository
? `npx @slicemachine/init --repository ${repository} --force`
: "npx @slicemachine/init --force";

process.stderr.write(
forced
? `Slice Machine is deprecated. Continuing because --force was passed.

The @slicemachine/init command is replaced by prismic init, which models content in the Type Builder:

${prismicInit}

Docs: https://prismic.io/docs/cli
`
: `Slice Machine is deprecated. The @slicemachine/init command is replaced by prismic init, which models content in the Type Builder:

${prismicInit}

const currentVersion = process.version;
--force sets up a project with the deprecated Slice Machine. It is not recommended:

if (!semver.satisfies(currentVersion, requiredVersion)) {
console.warn(
chalk.yellow(
`⚠️ Warning: You are using Node.js ${currentVersion}, but this tool requires ${requiredVersion}.\n` +
` Some features may not work correctly. Please upgrade your Node.js version.\n`,
),
);
${slicemachineInit}

Working with an AI agent? Install the Prismic skill so it knows the current workflow:

npx skills add --global --yes prismicio/skills

Docs: https://prismic.io/docs/cli
Existing Slice Machine projects: https://prismic.io/docs/slice-machine
`,
);

try {
const manager = createSliceMachineManager();
await manager.telemetry.initTelemetry({
appName: pkg.name,
appVersion: pkg.version,
});
const tracked = manager.telemetry
.track({
event: "command:init:deprecation",
repository,
forced,
})
// A forced run does not await this, so it must handle its own
// rejection. An unhandled one would take the process down.
.catch(() => undefined);
// A forced run has the rest of the command to deliver the event.
if (!forced) {
await Promise.race([tracked, setTimeout(3000)]);
}
} catch {
// Telemetry never blocks the message.
}

if (!forced) {
process.exit(1);
}

import("../dist/cli.cjs");
// The CLI parses its own flags and rejects unknown ones, so hide `--force`.
process.argv = process.argv.filter(
(argument) => argument !== "--force" && !argument.startsWith("--force="),
);
await import("../dist/cli.cjs");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
telemetry=false
116 changes: 116 additions & 0 deletions packages/init/test/bin.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { expect, it } from "vitest";
import { fileURLToPath } from "node:url";
import { execa } from "execa";

const BIN = fileURLToPath(
new URL("../bin/slicemachine-init.js", import.meta.url),
);

// The manager reads the user-level `.prismicrc` from `XDG_CONFIG_HOME`. The
// fixture's file disables telemetry so tests never reach Segment.
const XDG_CONFIG_HOME = fileURLToPath(
new URL("./__fixtures__/telemetry-disabled/", import.meta.url),
);
Comment thread
cursor[bot] marked this conversation as resolved.

const HALT = `Slice Machine is deprecated. The @slicemachine/init command is replaced by prismic init, which models content in the Type Builder:

npx prismic init

--force sets up a project with the deprecated Slice Machine. It is not recommended:

npx @slicemachine/init --force

Working with an AI agent? Install the Prismic skill so it knows the current workflow:

npx skills add --global --yes prismicio/skills

Docs: https://prismic.io/docs/cli
Existing Slice Machine projects: https://prismic.io/docs/slice-machine`;

const FORCED = `Slice Machine is deprecated. Continuing because --force was passed.

The @slicemachine/init command is replaced by prismic init, which models content in the Type Builder:

npx prismic init

Docs: https://prismic.io/docs/cli`;

const runBin = (args: string[]) => {
return execa(process.execPath, [BIN, ...args], {
env: { XDG_CONFIG_HOME },
reject: false,
});
};

it.each([
[],
["--help"],
["-h"],
["--version"],
["-v"],
["--starter", "nextjs-starter-prismic-minimal"],
["--no-push"],
["--unknown-flag"],
["--repository"],
["--force=false"],
])(
"prints the message to stderr and exits with code 1 (%j)",
async (...args) => {
const result = await runBin(args);

expect(result.exitCode).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr).toBe(HALT);
},
);

it.each([
["--repository", "my-repo"],
["--repository=my-repo"],
["-r", "my-repo"],
["-r=my-repo"],
["--no-push", "--repository", "my-repo", "--starter", "foo"],
])("carries the repository name into --repo (%j)", async (...args) => {
const result = await runBin(args);

expect(result.exitCode).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr).toBe(
HALT.replace(
" npx prismic init\n",
" npx prismic init --repo my-repo\n",
).replace(
"npx @slicemachine/init --force",
"npx @slicemachine/init --repository my-repo --force",
),
);
});

// `--force` hands off to the CLI, which is built into `dist/`. The unit tests
// run before that build, so these assert the notice, not the handoff. Every
// case passes a flag the CLI answers on its own so no run waits for input.
it.each([
["--force", "--version"],
["--version", "--force"],
["--force", "--help"],
["--force", "--no-push", "--starter", "foo", "--version"],
["--force=true", "--version"],
])("prints the notice and continues with --force (%j)", async (...args) => {
const result = await runBin(args);

expect(result.stderr.startsWith(FORCED)).toBe(true);
expect(result.stderr).not.toContain("add --force");
});

it.each([
["--force", "--repository", "my-repo", "--version"],
["--force", "-r=my-repo", "--version"],
])("carries the repository name into the notice (%j)", async (...args) => {
const result = await runBin(args);

expect(
result.stderr.startsWith(
FORCED.replace("npx prismic init", "npx prismic init --repo my-repo"),
),
).toBe(true);
});
8 changes: 8 additions & 0 deletions packages/manager/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> Slice Machine is replaced by the [Prismic CLI](https://prismic.io/docs/cli) and the [Type Builder](https://prismic.io/docs/type-builder). Existing projects are still supported. To move a project, see [Migrate to the Type Builder](https://prismic.io/docs/slice-machine#migrate-to-the-type-builder).
>
> Using an AI agent? Teach it the new way by installing the Prismic skill:
>
> ```bash
> npx skills add --global --yes prismicio/skills
> ```

> **Warning**
>
> This package is designed only for [Slice Machine][slice-machine]'s maintainers. If you use [Slice Machine][slice-machine] in your projects, you probably don't need to be aware of `@slicemachine/manager`.
Expand Down
8 changes: 8 additions & 0 deletions packages/manager/src/managers/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const SegmentEventType = {
command_init_start: "command:init:start",
command_init_identify: "command:init:identify",
command_init_end: "command:init:end",
command_init_deprecation: "command:init:deprecation",
sliceSimulator_open: "slice-simulator:open",
sliceSimulator_isNotRunning: "slice-simulator:is-not-running",
pageView: "page-view",
Expand Down Expand Up @@ -70,6 +71,7 @@ export const HumanSegmentEventType = {
[SegmentEventType.command_init_start]: "SliceMachine Init Start",
[SegmentEventType.command_init_identify]: "SliceMachine Init Identify",
[SegmentEventType.command_init_end]: "SliceMachine Init End",
[SegmentEventType.command_init_deprecation]: "SliceMachine Init Deprecation",
[SegmentEventType.sliceSimulator_open]: "SliceMachine Slice Simulator Open",
[SegmentEventType.sliceSimulator_isNotRunning]:
"SliceMachine Slice Simulator is not running",
Expand Down Expand Up @@ -181,6 +183,11 @@ type CommandInitEndSegmentEvent = SegmentEvent<
{ framework: string; success: boolean; starter?: string; error?: string }
>;

type CommandInitDeprecationSegmentEvent = SegmentEvent<
typeof SegmentEventType.command_init_deprecation,
{ forced: boolean }
>;

type SliceSimulatorOpenSegmentEvent = SegmentEvent<
typeof SegmentEventType.sliceSimulator_open
>;
Expand Down Expand Up @@ -590,6 +597,7 @@ export type SegmentEvents =
| CommandInitStartSegmentEvent
| CommandInitIdentifySegmentEvent
| CommandInitEndSegmentEvent
| CommandInitDeprecationSegmentEvent
| SliceSimulatorOpenSegmentEvent
| SliceSimulatorIsNotRunningSegmentEvent
| PageViewSegmentEvent
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-kit/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> Slice Machine is replaced by the [Prismic CLI](https://prismic.io/docs/cli) and the [Type Builder](https://prismic.io/docs/type-builder). Existing projects are still supported. To move a project, see [Migrate to the Type Builder](https://prismic.io/docs/slice-machine#migrate-to-the-type-builder).
>
> Using an AI agent? Teach it the new way by installing the Prismic skill:
>
> ```bash
> npx skills add --global --yes prismicio/skills
> ```

> **Warning**
>
> This package is designed for [Slice Machine][slice-machine] plugin authors. If you are not writing a plugin, you probably don't need to be aware of `@slicemachine/plugin-kit`.
Expand Down
8 changes: 8 additions & 0 deletions packages/slice-machine/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> Slice Machine is replaced by the [Prismic CLI](https://prismic.io/docs/cli) and the [Type Builder](https://prismic.io/docs/type-builder). Existing projects are still supported. To move a project, see [Migrate to the Type Builder](https://prismic.io/docs/slice-machine#migrate-to-the-type-builder).
>
> Using an AI agent? Teach it the new way by installing the Prismic skill:
>
> ```bash
> npx skills add --global --yes prismicio/skills
> ```

<p align="center">
<a href="https://prismic.io/slice-machine">
<img src="https://raw.githubusercontent.com/prismicio/slice-machine/main/.github/logo.svg" alt="Slice Machine logo" width="220" />
Expand Down
Loading
Loading