@slicemachine/adapter-nuxt 0.3.42-alpha.aa-sort-default-page-fields.1 → 0.3.42-alpha.aa-support-nuxt-4.1

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.
@@ -4,9 +4,9 @@ const path = require("node:path");
4
4
  const fs = require("@slicemachine/plugin-kit/fs");
5
5
  const commonTags = require("common-tags");
6
6
  const magicast = require("magicast");
7
+ const buildSrcPath = require("../lib/buildSrcPath.cjs");
7
8
  const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
8
9
  const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
9
- const checkHasSrcDirectory = require("../lib/checkHasSrcDirectory.cjs");
10
10
  function _interopNamespaceDefault(e) {
11
11
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
12
12
  if (e) {
@@ -30,21 +30,12 @@ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __f
30
30
  var _a;
31
31
  const NUXT_PRISMIC = "@nuxtjs/prismic";
32
32
  const installDependencies = async ({ installDependencies: installDependencies2 }) => {
33
- try {
34
- await installDependencies2({
35
- dependencies: {
36
- [NUXT_PRISMIC]: "^3.0.0"
37
- },
38
- dev: true
39
- });
40
- } catch (error) {
41
- await installDependencies2({
42
- dependencies: {
43
- [NUXT_PRISMIC]: "rc"
44
- },
45
- dev: true
46
- });
47
- }
33
+ await installDependencies2({
34
+ dependencies: {
35
+ [NUXT_PRISMIC]: "^3.3.0"
36
+ },
37
+ dev: true
38
+ });
48
39
  };
49
40
  const configurePrismicModule = async ({ helpers }) => {
50
41
  let nuxtConfigFilename = "nuxt.config.js";
@@ -90,11 +81,10 @@ const createSliceSimulatorPage = async ({ helpers, options }) => {
90
81
  helpers,
91
82
  options
92
83
  });
93
- const srcPagesDirectoryExists = await fs.checkHasProjectFile({
94
- filename: "src/pages",
84
+ const filename = await buildSrcPath.buildSrcPath({
85
+ filename: path__namespace.join("pages", "slice-simulator.vue"),
95
86
  helpers
96
87
  });
97
- const filename = path__namespace.join(srcPagesDirectoryExists ? "src/pages" : "pages", "slice-simulator.vue");
98
88
  if (await fs.checkHasProjectFile({ filename, helpers })) {
99
89
  return;
100
90
  }
@@ -111,11 +101,7 @@ const createSliceSimulatorPage = async ({ helpers, options }) => {
111
101
  });
112
102
  };
113
103
  const moveOrDeleteAppVue = async ({ helpers, options }) => {
114
- const srcDirectoryExists = await fs.checkHasProjectFile({
115
- filename: "src",
116
- helpers
117
- });
118
- const filenameAppVue = path__namespace.join(srcDirectoryExists ? "src" : "", "app.vue");
104
+ const filenameAppVue = await buildSrcPath.buildSrcPath({ filename: "app.vue", helpers });
119
105
  if (!await fs.checkHasProjectFile({ filename: filenameAppVue, helpers })) {
120
106
  return;
121
107
  }
@@ -127,11 +113,10 @@ const moveOrDeleteAppVue = async ({ helpers, options }) => {
127
113
  if (!filecontentAppVue.includes("<NuxtWelcome")) {
128
114
  return;
129
115
  }
130
- const srcPagesDirectoryExists = await fs.checkHasProjectFile({
131
- filename: "src/pages",
116
+ const filenameIndexVue = await buildSrcPath.buildSrcPath({
117
+ filename: path__namespace.join("pages/index.vue"),
132
118
  helpers
133
119
  });
134
- const filenameIndexVue = path__namespace.join(srcPagesDirectoryExists ? "src/pages" : "pages", "index.vue");
135
120
  if (!await fs.checkHasProjectFile({ filename: filenameIndexVue, helpers })) {
136
121
  await fs.writeProjectFile({
137
122
  filename: filenameIndexVue,
@@ -147,15 +132,22 @@ const moveOrDeleteAppVue = async ({ helpers, options }) => {
147
132
  };
148
133
  const modifySliceMachineConfig = async ({ helpers, options, actions }) => {
149
134
  var _a2;
150
- const hasSrcDirectory = await checkHasSrcDirectory.checkHasSrcDirectory({ helpers });
135
+ const hasAppDirectory = await fs.checkHasProjectFile({
136
+ filename: "app",
137
+ helpers
138
+ });
139
+ const hasSrcDirectory = await fs.checkHasProjectFile({
140
+ filename: "src",
141
+ helpers
142
+ });
151
143
  const project = await helpers.getProject();
152
144
  (_a2 = project.config).localSliceSimulatorURL || (_a2.localSliceSimulatorURL = "http://localhost:3000/slice-simulator");
153
- if (hasSrcDirectory && project.config.libraries && JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])) {
145
+ if ((hasAppDirectory || hasSrcDirectory) && project.config.libraries && JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])) {
154
146
  const sliceLibrary = await actions.readSliceLibrary({
155
147
  libraryID: project.config.libraries[0]
156
148
  });
157
149
  if (sliceLibrary.sliceIDs.length < 1) {
158
- project.config.libraries = ["./src/slices"];
150
+ project.config.libraries = hasAppDirectory ? ["./app/slices"] : ["./src/slices"];
159
151
  }
160
152
  }
161
153
  await helpers.updateSliceMachineConfig(project.config, {
@@ -1 +1 @@
1
- {"version":3,"file":"project-init.cjs","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\tdeleteProjectFile,\n\treadProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\nimport { builders, loadFile, writeFile } from \"magicast\";\n\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { checkHasSrcDirectory } from \"../lib/checkHasSrcDirectory\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst NUXT_PRISMIC = \"@nuxtjs/prismic\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\ttry {\n\t\tawait installDependencies({\n\t\t\tdependencies: {\n\t\t\t\t[NUXT_PRISMIC]: \"^3.0.0\",\n\t\t\t},\n\t\t\tdev: true,\n\t\t});\n\t} catch (error) {\n\t\t// TODO: Remove when latest is published and documented\n\t\t// Fallback to RC if latest is still not available\n\t\tawait installDependencies({\n\t\t\tdependencies: {\n\t\t\t\t[NUXT_PRISMIC]: \"rc\",\n\t\t\t},\n\t\t\tdev: true,\n\t\t});\n\t}\n};\n\ntype ConfigurePrismicModuleArgs = SliceMachineContext<PluginOptions>;\n\nconst configurePrismicModule = async ({\n\thelpers,\n}: ConfigurePrismicModuleArgs) => {\n\tlet nuxtConfigFilename = \"nuxt.config.js\";\n\n\tif (!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))) {\n\t\tnuxtConfigFilename = \"nuxt.config.ts\";\n\n\t\t// nuxt.config.* not found\n\t\tif (\n\t\t\t!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst nuxtConfigPath = helpers.joinPathFromRoot(nuxtConfigFilename);\n\n\tconst mod = await loadFile(nuxtConfigPath);\n\tconst config =\n\t\tmod.exports.default.$type === \"function-call\"\n\t\t\t? mod.exports.default.$args[0]\n\t\t\t: mod.exports.default;\n\n\t// Register Prismic module\n\tlet hasInlinedConfiguration = false;\n\tconst hasPrismicModuleRegistered = (config.modules || []).find(\n\t\t(registration: string | [string, unknown]) => {\n\t\t\tif (typeof registration === \"string\") {\n\t\t\t\treturn registration === NUXT_PRISMIC;\n\t\t\t} else if (Array.isArray(registration)) {\n\t\t\t\thasInlinedConfiguration = !!registration[1];\n\n\t\t\t\treturn registration[0] === NUXT_PRISMIC;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t);\n\n\tif (!hasPrismicModuleRegistered) {\n\t\tconfig.modules ||= [];\n\t\tconfig.modules.push(NUXT_PRISMIC);\n\t}\n\n\t// Append Prismic module configuration\n\tif (!hasInlinedConfiguration) {\n\t\t// Import Slice Machine configuration\n\t\tmod.imports.$add({\n\t\t\tfrom: \"./slicemachine.config.json\",\n\t\t\timported: \"apiEndpoint\",\n\t\t});\n\t\tmod.imports.$add({\n\t\t\tfrom: \"./slicemachine.config.json\",\n\t\t\timported: \"repositoryName\",\n\t\t});\n\n\t\t// Add inline configuration\n\t\tconfig.prismic ||= {};\n\t\tconfig.prismic.endpoint = builders.raw(\"apiEndpoint || repositoryName\");\n\t}\n\n\tawait writeFile(mod, nuxtConfigPath);\n};\n\ntype CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst srcPagesDirectoryExists = await checkHasProjectFile({\n\t\tfilename: \"src/pages\",\n\t\thelpers,\n\t});\n\n\tconst filename = path.join(\n\t\tsrcPagesDirectoryExists ? \"src/pages\" : \"pages\",\n\t\t\"slice-simulator.vue\",\n\t);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst scriptAttributes = [\"setup\"];\n\tif (isTypeScriptProject) {\n\t\tscriptAttributes.push('lang=\"ts\"');\n\t}\n\n\tconst contents = stripIndent`\n\t\t<template>\n\t\t\t<SliceSimulator #default=\"{ slices }\">\n\t\t\t\t<SliceZone :slices=\"slices\" :components=\"components\" />\n\t\t\t</SliceSimulator>\n\t\t</template>\n\n\t\t<script ${scriptAttributes.join(\" \")}>\n\t\timport { SliceSimulator } from \"@slicemachine/adapter-nuxt/simulator\";\n\t\timport { components } from \"~/slices\";\n\t\t</script>\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst moveOrDeleteAppVue = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst srcDirectoryExists = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\n\tconst filenameAppVue = path.join(srcDirectoryExists ? \"src\" : \"\", \"app.vue\");\n\n\t// If there's not `app.vue`, there's nothing to do.\n\tif (!(await checkHasProjectFile({ filename: filenameAppVue, helpers }))) {\n\t\treturn;\n\t}\n\n\tconst filecontentAppVue = await readProjectFile({\n\t\tfilename: filenameAppVue,\n\t\thelpers,\n\t\tencoding: \"utf-8\",\n\t});\n\n\t// We check for app.vue to contain Nuxt default welcome component to determine if we need to consider it as the default one or not.\n\tif (!filecontentAppVue.includes(\"<NuxtWelcome\")) {\n\t\treturn;\n\t}\n\n\tconst srcPagesDirectoryExists = await checkHasProjectFile({\n\t\tfilename: \"src/pages\",\n\t\thelpers,\n\t});\n\n\tconst filenameIndexVue = path.join(\n\t\tsrcPagesDirectoryExists ? \"src/pages\" : \"pages\",\n\t\t\"index.vue\",\n\t);\n\n\t// If we don't have an `index.vue` we create one with the content of `app.vue`\n\tif (!(await checkHasProjectFile({ filename: filenameIndexVue, helpers }))) {\n\t\tawait writeProjectFile({\n\t\t\tfilename: filenameIndexVue,\n\t\t\tcontents: filecontentAppVue,\n\t\t\tformat: options.format,\n\t\t\thelpers,\n\t\t});\n\t}\n\n\t// Delete `app.vue`\n\tawait deleteProjectFile({\n\t\tfilename: filenameAppVue,\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasSrcDirectory = await checkHasSrcDirectory({ helpers });\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:3000/slice-simulator\";\n\n\t// Nest the default Slice Library in the src directory if it exists and\n\t// is empty.\n\tif (\n\t\thasSrcDirectory &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = [\"./src/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tconfigurePrismicModule(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tmoveOrDeleteAppVue(context),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t]),\n\t);\n};\n"],"names":["installDependencies","checkHasProjectFile","loadFile","builders","writeFile","checkIsTypeScriptProject","path","stripIndent","writeProjectFile","readProjectFile","deleteProjectFile","checkHasSrcDirectory","_a","rejectIfNecessary"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA;AAqBA,MAAM,eAAe;AAMrB,MAAM,sBAAsB,OAAO,EAClC,qBAAAA,2BAC6B;AACzB,MAAA;AACH,UAAMA,qBAAoB;AAAA,MACzB,cAAc;AAAA,QACb,CAAC,YAAY,GAAG;AAAA,MAChB;AAAA,MACD,KAAK;AAAA,IAAA,CACL;AAAA,WACO;AAGR,UAAMA,qBAAoB;AAAA,MACzB,cAAc;AAAA,QACb,CAAC,YAAY,GAAG;AAAA,MAChB;AAAA,MACD,KAAK;AAAA,IAAA,CACL;AAAA,EACD;AACF;AAIA,MAAM,yBAAyB,OAAO,EACrC,cACgC;AAChC,MAAI,qBAAqB;AAErB,MAAA,CAAE,MAAMC,GAAAA,oBAAoB,EAAE,UAAU,oBAAoB,QAAA,CAAS,GAAI;AACvD,yBAAA;AAIpB,QAAA,CAAE,MAAMA,GAAAA,oBAAoB,EAAE,UAAU,oBAAoB,QAAA,CAAS,GACpE;AACD;AAAA,IACA;AAAA,EACD;AAEK,QAAA,iBAAiB,QAAQ,iBAAiB,kBAAkB;AAE5D,QAAA,MAAM,MAAMC,kBAAS,cAAc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,QAAQ;AAG9B,GAAAC,MAAA,QAAQ,QAAO,2BAAfA,IAAe,yBACd;AAID,MACC,mBACA,QAAQ,OAAO,aACf,KAAK,UAAU,QAAQ,OAAO,SAAS,MAAM,KAAK,UAAU,CAAC,UAAU,CAAC,GACvE;AACK,UAAA,eAAe,MAAM,QAAQ,iBAAiB;AAAA,MACnD,WAAW,QAAQ,OAAO,UAAU,CAAC;AAAA,IAAA,CACrC;AAEG,QAAA,aAAa,SAAS,SAAS,GAAG;AAC7B,cAAA,OAAO,YAAY,CAAC,cAAc;AAAA,IAC1C;AAAA,EACD;AAEK,QAAA,QAAQ,yBAAyB,QAAQ,QAAQ;AAAA,IACtD,QAAQ,QAAQ;AAAA,EAAA,CAChB;AACF;AAEO,MAAM,cAA8C,OAC1D,EAAE,qBAAqB,qBAAA,GACvB,YACG;AAEFC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,oBAAoB,EAAE,qBAAqB,sBAAsB;AAAA,IACjE,uBAAuB,OAAO;AAAA,IAC9B,yBAAyB,OAAO;AAAA,IAChC,mBAAmB,OAAO;AAAA,IAC1B,yBAAyB,OAAO;AAAA,EAChC,CAAA,CAAC;AAEJ;;"}
1
+ {"version":3,"file":"project-init.cjs","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\tdeleteProjectFile,\n\treadProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\nimport { builders, loadFile, writeFile } from \"magicast\";\n\nimport { buildSrcPath } from \"../lib/buildSrcPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst NUXT_PRISMIC = \"@nuxtjs/prismic\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\tawait installDependencies({\n\t\tdependencies: {\n\t\t\t[NUXT_PRISMIC]: \"^3.3.0\",\n\t\t},\n\t\tdev: true,\n\t});\n};\n\ntype ConfigurePrismicModuleArgs = SliceMachineContext<PluginOptions>;\n\nconst configurePrismicModule = async ({\n\thelpers,\n}: ConfigurePrismicModuleArgs) => {\n\tlet nuxtConfigFilename = \"nuxt.config.js\";\n\n\tif (!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))) {\n\t\tnuxtConfigFilename = \"nuxt.config.ts\";\n\n\t\t// nuxt.config.* not found\n\t\tif (\n\t\t\t!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst nuxtConfigPath = helpers.joinPathFromRoot(nuxtConfigFilename);\n\n\tconst mod = await loadFile(nuxtConfigPath);\n\tconst config =\n\t\tmod.exports.default.$type === \"function-call\"\n\t\t\t? mod.exports.default.$args[0]\n\t\t\t: mod.exports.default;\n\n\t// Register Prismic module\n\tlet hasInlinedConfiguration = false;\n\tconst hasPrismicModuleRegistered = (config.modules || []).find(\n\t\t(registration: string | [string, unknown]) => {\n\t\t\tif (typeof registration === \"string\") {\n\t\t\t\treturn registration === NUXT_PRISMIC;\n\t\t\t} else if (Array.isArray(registration)) {\n\t\t\t\thasInlinedConfiguration = !!registration[1];\n\n\t\t\t\treturn registration[0] === NUXT_PRISMIC;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t);\n\n\tif (!hasPrismicModuleRegistered) {\n\t\tconfig.modules ||= [];\n\t\tconfig.modules.push(NUXT_PRISMIC);\n\t}\n\n\t// Append Prismic module configuration\n\tif (!hasInlinedConfiguration) {\n\t\t// Import Slice Machine configuration\n\t\tmod.imports.$add({\n\t\t\tfrom: \"./slicemachine.config.json\",\n\t\t\timported: \"apiEndpoint\",\n\t\t});\n\t\tmod.imports.$add({\n\t\t\tfrom: \"./slicemachine.config.json\",\n\t\t\timported: \"repositoryName\",\n\t\t});\n\n\t\t// Add inline configuration\n\t\tconfig.prismic ||= {};\n\t\tconfig.prismic.endpoint = builders.raw(\"apiEndpoint || repositoryName\");\n\t}\n\n\tawait writeFile(mod, nuxtConfigPath);\n};\n\ntype CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst filename = await buildSrcPath({\n\t\tfilename: path.join(\"pages\", \"slice-simulator.vue\"),\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst scriptAttributes = [\"setup\"];\n\tif (isTypeScriptProject) {\n\t\tscriptAttributes.push('lang=\"ts\"');\n\t}\n\n\tconst contents = stripIndent`\n\t\t<template>\n\t\t\t<SliceSimulator #default=\"{ slices }\">\n\t\t\t\t<SliceZone :slices=\"slices\" :components=\"components\" />\n\t\t\t</SliceSimulator>\n\t\t</template>\n\n\t\t<script ${scriptAttributes.join(\" \")}>\n\t\timport { SliceSimulator } from \"@slicemachine/adapter-nuxt/simulator\";\n\t\timport { components } from \"~/slices\";\n\t\t</script>\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst moveOrDeleteAppVue = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst filenameAppVue = await buildSrcPath({ filename: \"app.vue\", helpers });\n\n\t// If there's no `app.vue`, there's nothing to do.\n\tif (!(await checkHasProjectFile({ filename: filenameAppVue, helpers }))) {\n\t\treturn;\n\t}\n\n\tconst filecontentAppVue = await readProjectFile({\n\t\tfilename: filenameAppVue,\n\t\thelpers,\n\t\tencoding: \"utf-8\",\n\t});\n\n\t// We check for app.vue to contain Nuxt default welcome component to determine\n\t// if we need to consider it as the default one or not.\n\tif (!filecontentAppVue.includes(\"<NuxtWelcome\")) {\n\t\treturn;\n\t}\n\n\tconst filenameIndexVue = await buildSrcPath({\n\t\tfilename: path.join(\"pages/index.vue\"),\n\t\thelpers,\n\t});\n\n\t// If we don't have an `index.vue` we create one with the content of `app.vue`\n\tif (!(await checkHasProjectFile({ filename: filenameIndexVue, helpers }))) {\n\t\tawait writeProjectFile({\n\t\t\tfilename: filenameIndexVue,\n\t\t\tcontents: filecontentAppVue,\n\t\t\tformat: options.format,\n\t\t\thelpers,\n\t\t});\n\t}\n\n\t// Delete `app.vue`\n\tawait deleteProjectFile({\n\t\tfilename: filenameAppVue,\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppDirectory = await checkHasProjectFile({\n\t\tfilename: \"app\",\n\t\thelpers,\n\t});\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:3000/slice-simulator\";\n\n\t// Nest the default Slice Library in the `app` or `src` directory if it\n\t// exists and is empty.\n\tif (\n\t\t(hasAppDirectory || hasSrcDirectory) &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = hasAppDirectory\n\t\t\t\t? [\"./app/slices\"]\n\t\t\t\t: [\"./src/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tconfigurePrismicModule(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tmoveOrDeleteAppVue(context),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t]),\n\t);\n};\n"],"names":["installDependencies","checkHasProjectFile","loadFile","builders","writeFile","checkIsTypeScriptProject","buildSrcPath","path","stripIndent","writeProjectFile","readProjectFile","deleteProjectFile","_a","rejectIfNecessary"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA;AAqBA,MAAM,eAAe;AAMrB,MAAM,sBAAsB,OAAO,EAClC,qBAAAA,2BAC6B;AAC7B,QAAMA,qBAAoB;AAAA,IACzB,cAAc;AAAA,MACb,CAAC,YAAY,GAAG;AAAA,IAChB;AAAA,IACD,KAAK;AAAA,EAAA,CACL;AACF;AAIA,MAAM,yBAAyB,OAAO,EACrC,cACgC;AAChC,MAAI,qBAAqB;AAErB,MAAA,CAAE,MAAMC,GAAAA,oBAAoB,EAAE,UAAU,oBAAoB,QAAA,CAAS,GAAI;AACvD,yBAAA;AAIpB,QAAA,CAAE,MAAMA,GAAAA,oBAAoB,EAAE,UAAU,oBAAoB,QAAA,CAAS,GACpE;AACD;AAAA,IACA;AAAA,EACD;AAEK,QAAA,iBAAiB,QAAQ,iBAAiB,kBAAkB;AAE5D,QAAA,MAAM,MAAMC,kBAAS,cAAc;AACzC,QAAM,SACL,IAAI,QAAQ,QAAQ,UAAU,kBAC3B,IAAI,QAAQ,QAAQ,MAAM,CAAC,IAC3B,IAAI,QAAQ;AAGhB,MAAI,0BAA0B;AAC9B,QAAM,8BAA8B,OAAO,WAAW,CAA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MACnD,WAAW,QAAQ,OAAO,UAAU,CAAC;AAAA,IAAA,CACrC;AAEG,QAAA,aAAa,SAAS,SAAS,GAAG;AACrC,cAAQ,OAAO,YAAY,kBACxB,CAAC,cAAc,IACf,CAAC,cAAc;AAAA,IAClB;AAAA,EACD;AAEK,QAAA,QAAQ,yBAAyB,QAAQ,QAAQ;AAAA,IACtD,QAAQ,QAAQ;AAAA,EAAA,CAChB;AACF;AAEO,MAAM,cAA8C,OAC1D,EAAE,qBAAqB,qBAAA,GACvB,YACG;AAEFC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,oBAAoB,EAAE,qBAAqB,sBAAsB;AAAA,IACjE,uBAAuB,OAAO;AAAA,IAC9B,yBAAyB,OAAO;AAAA,IAChC,mBAAmB,OAAO;AAAA,IAC1B,yBAAyB,OAAO;AAAA,EAChC,CAAA,CAAC;AAEJ;;"}
@@ -2,30 +2,21 @@ import * as path from "node:path";
2
2
  import { checkHasProjectFile, writeProjectFile, readProjectFile, deleteProjectFile } from "@slicemachine/plugin-kit/fs";
3
3
  import { stripIndent } from "common-tags";
4
4
  import { loadFile, builders, writeFile } from "magicast";
5
+ import { buildSrcPath } from "../lib/buildSrcPath.js";
5
6
  import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
6
7
  import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
7
- import { checkHasSrcDirectory } from "../lib/checkHasSrcDirectory.js";
8
8
  var __freeze = Object.freeze;
9
9
  var __defProp = Object.defineProperty;
10
10
  var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
11
11
  var _a;
12
12
  const NUXT_PRISMIC = "@nuxtjs/prismic";
13
13
  const installDependencies = async ({ installDependencies: installDependencies2 }) => {
14
- try {
15
- await installDependencies2({
16
- dependencies: {
17
- [NUXT_PRISMIC]: "^3.0.0"
18
- },
19
- dev: true
20
- });
21
- } catch (error) {
22
- await installDependencies2({
23
- dependencies: {
24
- [NUXT_PRISMIC]: "rc"
25
- },
26
- dev: true
27
- });
28
- }
14
+ await installDependencies2({
15
+ dependencies: {
16
+ [NUXT_PRISMIC]: "^3.3.0"
17
+ },
18
+ dev: true
19
+ });
29
20
  };
30
21
  const configurePrismicModule = async ({ helpers }) => {
31
22
  let nuxtConfigFilename = "nuxt.config.js";
@@ -71,11 +62,10 @@ const createSliceSimulatorPage = async ({ helpers, options }) => {
71
62
  helpers,
72
63
  options
73
64
  });
74
- const srcPagesDirectoryExists = await checkHasProjectFile({
75
- filename: "src/pages",
65
+ const filename = await buildSrcPath({
66
+ filename: path.join("pages", "slice-simulator.vue"),
76
67
  helpers
77
68
  });
78
- const filename = path.join(srcPagesDirectoryExists ? "src/pages" : "pages", "slice-simulator.vue");
79
69
  if (await checkHasProjectFile({ filename, helpers })) {
80
70
  return;
81
71
  }
@@ -92,11 +82,7 @@ const createSliceSimulatorPage = async ({ helpers, options }) => {
92
82
  });
93
83
  };
94
84
  const moveOrDeleteAppVue = async ({ helpers, options }) => {
95
- const srcDirectoryExists = await checkHasProjectFile({
96
- filename: "src",
97
- helpers
98
- });
99
- const filenameAppVue = path.join(srcDirectoryExists ? "src" : "", "app.vue");
85
+ const filenameAppVue = await buildSrcPath({ filename: "app.vue", helpers });
100
86
  if (!await checkHasProjectFile({ filename: filenameAppVue, helpers })) {
101
87
  return;
102
88
  }
@@ -108,11 +94,10 @@ const moveOrDeleteAppVue = async ({ helpers, options }) => {
108
94
  if (!filecontentAppVue.includes("<NuxtWelcome")) {
109
95
  return;
110
96
  }
111
- const srcPagesDirectoryExists = await checkHasProjectFile({
112
- filename: "src/pages",
97
+ const filenameIndexVue = await buildSrcPath({
98
+ filename: path.join("pages/index.vue"),
113
99
  helpers
114
100
  });
115
- const filenameIndexVue = path.join(srcPagesDirectoryExists ? "src/pages" : "pages", "index.vue");
116
101
  if (!await checkHasProjectFile({ filename: filenameIndexVue, helpers })) {
117
102
  await writeProjectFile({
118
103
  filename: filenameIndexVue,
@@ -128,15 +113,22 @@ const moveOrDeleteAppVue = async ({ helpers, options }) => {
128
113
  };
129
114
  const modifySliceMachineConfig = async ({ helpers, options, actions }) => {
130
115
  var _a2;
131
- const hasSrcDirectory = await checkHasSrcDirectory({ helpers });
116
+ const hasAppDirectory = await checkHasProjectFile({
117
+ filename: "app",
118
+ helpers
119
+ });
120
+ const hasSrcDirectory = await checkHasProjectFile({
121
+ filename: "src",
122
+ helpers
123
+ });
132
124
  const project = await helpers.getProject();
133
125
  (_a2 = project.config).localSliceSimulatorURL || (_a2.localSliceSimulatorURL = "http://localhost:3000/slice-simulator");
134
- if (hasSrcDirectory && project.config.libraries && JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])) {
126
+ if ((hasAppDirectory || hasSrcDirectory) && project.config.libraries && JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])) {
135
127
  const sliceLibrary = await actions.readSliceLibrary({
136
128
  libraryID: project.config.libraries[0]
137
129
  });
138
130
  if (sliceLibrary.sliceIDs.length < 1) {
139
- project.config.libraries = ["./src/slices"];
131
+ project.config.libraries = hasAppDirectory ? ["./app/slices"] : ["./src/slices"];
140
132
  }
141
133
  }
142
134
  await helpers.updateSliceMachineConfig(project.config, {
@@ -1 +1 @@
1
- {"version":3,"file":"project-init.js","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\tdeleteProjectFile,\n\treadProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\nimport { builders, loadFile, writeFile } from \"magicast\";\n\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { checkHasSrcDirectory } from \"../lib/checkHasSrcDirectory\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst NUXT_PRISMIC = \"@nuxtjs/prismic\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\ttry {\n\t\tawait installDependencies({\n\t\t\tdependencies: {\n\t\t\t\t[NUXT_PRISMIC]: \"^3.0.0\",\n\t\t\t},\n\t\t\tdev: true,\n\t\t});\n\t} catch (error) {\n\t\t// TODO: Remove when latest is published and documented\n\t\t// Fallback to RC if latest is still not available\n\t\tawait installDependencies({\n\t\t\tdependencies: {\n\t\t\t\t[NUXT_PRISMIC]: \"rc\",\n\t\t\t},\n\t\t\tdev: true,\n\t\t});\n\t}\n};\n\ntype ConfigurePrismicModuleArgs = SliceMachineContext<PluginOptions>;\n\nconst configurePrismicModule = async ({\n\thelpers,\n}: ConfigurePrismicModuleArgs) => {\n\tlet nuxtConfigFilename = \"nuxt.config.js\";\n\n\tif (!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))) {\n\t\tnuxtConfigFilename = \"nuxt.config.ts\";\n\n\t\t// nuxt.config.* not found\n\t\tif (\n\t\t\t!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst nuxtConfigPath = helpers.joinPathFromRoot(nuxtConfigFilename);\n\n\tconst mod = await loadFile(nuxtConfigPath);\n\tconst config =\n\t\tmod.exports.default.$type === \"function-call\"\n\t\t\t? mod.exports.default.$args[0]\n\t\t\t: mod.exports.default;\n\n\t// Register Prismic module\n\tlet hasInlinedConfiguration = false;\n\tconst hasPrismicModuleRegistered = (config.modules || []).find(\n\t\t(registration: string | [string, unknown]) => {\n\t\t\tif (typeof registration === \"string\") {\n\t\t\t\treturn registration === NUXT_PRISMIC;\n\t\t\t} else if (Array.isArray(registration)) {\n\t\t\t\thasInlinedConfiguration = !!registration[1];\n\n\t\t\t\treturn registration[0] === NUXT_PRISMIC;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t);\n\n\tif (!hasPrismicModuleRegistered) {\n\t\tconfig.modules ||= [];\n\t\tconfig.modules.push(NUXT_PRISMIC);\n\t}\n\n\t// Append Prismic module configuration\n\tif (!hasInlinedConfiguration) {\n\t\t// Import Slice Machine configuration\n\t\tmod.imports.$add({\n\t\t\tfrom: \"./slicemachine.config.json\",\n\t\t\timported: \"apiEndpoint\",\n\t\t});\n\t\tmod.imports.$add({\n\t\t\tfrom: \"./slicemachine.config.json\",\n\t\t\timported: \"repositoryName\",\n\t\t});\n\n\t\t// Add inline configuration\n\t\tconfig.prismic ||= {};\n\t\tconfig.prismic.endpoint = builders.raw(\"apiEndpoint || repositoryName\");\n\t}\n\n\tawait writeFile(mod, nuxtConfigPath);\n};\n\ntype CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst srcPagesDirectoryExists = await checkHasProjectFile({\n\t\tfilename: \"src/pages\",\n\t\thelpers,\n\t});\n\n\tconst filename = path.join(\n\t\tsrcPagesDirectoryExists ? \"src/pages\" : \"pages\",\n\t\t\"slice-simulator.vue\",\n\t);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst scriptAttributes = [\"setup\"];\n\tif (isTypeScriptProject) {\n\t\tscriptAttributes.push('lang=\"ts\"');\n\t}\n\n\tconst contents = stripIndent`\n\t\t<template>\n\t\t\t<SliceSimulator #default=\"{ slices }\">\n\t\t\t\t<SliceZone :slices=\"slices\" :components=\"components\" />\n\t\t\t</SliceSimulator>\n\t\t</template>\n\n\t\t<script ${scriptAttributes.join(\" \")}>\n\t\timport { SliceSimulator } from \"@slicemachine/adapter-nuxt/simulator\";\n\t\timport { components } from \"~/slices\";\n\t\t</script>\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst moveOrDeleteAppVue = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst srcDirectoryExists = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\n\tconst filenameAppVue = path.join(srcDirectoryExists ? \"src\" : \"\", \"app.vue\");\n\n\t// If there's not `app.vue`, there's nothing to do.\n\tif (!(await checkHasProjectFile({ filename: filenameAppVue, helpers }))) {\n\t\treturn;\n\t}\n\n\tconst filecontentAppVue = await readProjectFile({\n\t\tfilename: filenameAppVue,\n\t\thelpers,\n\t\tencoding: \"utf-8\",\n\t});\n\n\t// We check for app.vue to contain Nuxt default welcome component to determine if we need to consider it as the default one or not.\n\tif (!filecontentAppVue.includes(\"<NuxtWelcome\")) {\n\t\treturn;\n\t}\n\n\tconst srcPagesDirectoryExists = await checkHasProjectFile({\n\t\tfilename: \"src/pages\",\n\t\thelpers,\n\t});\n\n\tconst filenameIndexVue = path.join(\n\t\tsrcPagesDirectoryExists ? \"src/pages\" : \"pages\",\n\t\t\"index.vue\",\n\t);\n\n\t// If we don't have an `index.vue` we create one with the content of `app.vue`\n\tif (!(await checkHasProjectFile({ filename: filenameIndexVue, helpers }))) {\n\t\tawait writeProjectFile({\n\t\t\tfilename: filenameIndexVue,\n\t\t\tcontents: filecontentAppVue,\n\t\t\tformat: options.format,\n\t\t\thelpers,\n\t\t});\n\t}\n\n\t// Delete `app.vue`\n\tawait deleteProjectFile({\n\t\tfilename: filenameAppVue,\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasSrcDirectory = await checkHasSrcDirectory({ helpers });\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:3000/slice-simulator\";\n\n\t// Nest the default Slice Library in the src directory if it exists and\n\t// is empty.\n\tif (\n\t\thasSrcDirectory &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = [\"./src/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tconfigurePrismicModule(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tmoveOrDeleteAppVue(context),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t]),\n\t);\n};\n"],"names":["installDependencies","_a"],"mappings":";;;;;;;;;;AAAA,IAAA;AAqBA,MAAM,eAAe;AAMrB,MAAM,sBAAsB,OAAO,EAClC,qBAAAA,2BAC6B;AACzB,MAAA;AACH,UAAMA,qBAAoB;AAAA,MACzB,cAAc;AAAA,QACb,CAAC,YAAY,GAAG;AAAA,MAChB;AAAA,MACD,KAAK;AAAA,IAAA,CACL;AAAA,WACO;AAGR,UAAMA,qBAAoB;AAAA,MACzB,cAAc;AAAA,QACb,CAAC,YAAY,GAAG;AAAA,MAChB;AAAA,MACD,KAAK;AAAA,IAAA,CACL;AAAA,EACD;AACF;AAIA,MAAM,yBAAyB,OAAO,EACrC,cACgC;AAChC,MAAI,qBAAqB;AAErB,MAAA,CAAE,MAAM,oBAAoB,EAAE,UAAU,oBAAoB,QAAA,CAAS,GAAI;AACvD,yBAAA;AAIpB,QAAA,CAAE,MAAM,oBAAo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;AACxC,QAAM,kBAAkB,MAAM,qBAAqB,EAAE,QAAS,CAAA;AACxD,QAAA,UAAU,MAAM,QAAQ;AAG9B,GAAAC,MAAA,QAAQ,QAAO,2BAAfA,IAAe,yBACd;AAID,MACC,mBACA,QAAQ,OAAO,aACf,KAAK,UAAU,QAAQ,OAAO,SAAS,MAAM,KAAK,UAAU,CAAC,UAAU,CAAC,GACvE;AACK,UAAA,eAAe,MAAM,QAAQ,iBAAiB;AAAA,MACnD,WAAW,QAAQ,OAAO,UAAU,CAAC;AAAA,IAAA,CACrC;AAEG,QAAA,aAAa,SAAS,SAAS,GAAG;AAC7B,cAAA,OAAO,YAAY,CAAC,cAAc;AAAA,IAC1C;AAAA,EACD;AAEK,QAAA,QAAQ,yBAAyB,QAAQ,QAAQ;AAAA,IACtD,QAAQ,QAAQ;AAAA,EAAA,CAChB;AACF;AAEO,MAAM,cAA8C,OAC1D,EAAE,qBAAqB,qBAAA,GACvB,YACG;AAEF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,oBAAoB,EAAE,qBAAqB,sBAAsB;AAAA,IACjE,uBAAuB,OAAO;AAAA,IAC9B,yBAAyB,OAAO;AAAA,IAChC,mBAAmB,OAAO;AAAA,IAC1B,yBAAyB,OAAO;AAAA,EAChC,CAAA,CAAC;AAEJ;"}
1
+ {"version":3,"file":"project-init.js","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\tdeleteProjectFile,\n\treadProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\nimport { builders, loadFile, writeFile } from \"magicast\";\n\nimport { buildSrcPath } from \"../lib/buildSrcPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst NUXT_PRISMIC = \"@nuxtjs/prismic\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\tawait installDependencies({\n\t\tdependencies: {\n\t\t\t[NUXT_PRISMIC]: \"^3.3.0\",\n\t\t},\n\t\tdev: true,\n\t});\n};\n\ntype ConfigurePrismicModuleArgs = SliceMachineContext<PluginOptions>;\n\nconst configurePrismicModule = async ({\n\thelpers,\n}: ConfigurePrismicModuleArgs) => {\n\tlet nuxtConfigFilename = \"nuxt.config.js\";\n\n\tif (!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))) {\n\t\tnuxtConfigFilename = \"nuxt.config.ts\";\n\n\t\t// nuxt.config.* not found\n\t\tif (\n\t\t\t!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst nuxtConfigPath = helpers.joinPathFromRoot(nuxtConfigFilename);\n\n\tconst mod = await loadFile(nuxtConfigPath);\n\tconst config =\n\t\tmod.exports.default.$type === \"function-call\"\n\t\t\t? mod.exports.default.$args[0]\n\t\t\t: mod.exports.default;\n\n\t// Register Prismic module\n\tlet hasInlinedConfiguration = false;\n\tconst hasPrismicModuleRegistered = (config.modules || []).find(\n\t\t(registration: string | [string, unknown]) => {\n\t\t\tif (typeof registration === \"string\") {\n\t\t\t\treturn registration === NUXT_PRISMIC;\n\t\t\t} else if (Array.isArray(registration)) {\n\t\t\t\thasInlinedConfiguration = !!registration[1];\n\n\t\t\t\treturn registration[0] === NUXT_PRISMIC;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t);\n\n\tif (!hasPrismicModuleRegistered) {\n\t\tconfig.modules ||= [];\n\t\tconfig.modules.push(NUXT_PRISMIC);\n\t}\n\n\t// Append Prismic module configuration\n\tif (!hasInlinedConfiguration) {\n\t\t// Import Slice Machine configuration\n\t\tmod.imports.$add({\n\t\t\tfrom: \"./slicemachine.config.json\",\n\t\t\timported: \"apiEndpoint\",\n\t\t});\n\t\tmod.imports.$add({\n\t\t\tfrom: \"./slicemachine.config.json\",\n\t\t\timported: \"repositoryName\",\n\t\t});\n\n\t\t// Add inline configuration\n\t\tconfig.prismic ||= {};\n\t\tconfig.prismic.endpoint = builders.raw(\"apiEndpoint || repositoryName\");\n\t}\n\n\tawait writeFile(mod, nuxtConfigPath);\n};\n\ntype CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst filename = await buildSrcPath({\n\t\tfilename: path.join(\"pages\", \"slice-simulator.vue\"),\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst scriptAttributes = [\"setup\"];\n\tif (isTypeScriptProject) {\n\t\tscriptAttributes.push('lang=\"ts\"');\n\t}\n\n\tconst contents = stripIndent`\n\t\t<template>\n\t\t\t<SliceSimulator #default=\"{ slices }\">\n\t\t\t\t<SliceZone :slices=\"slices\" :components=\"components\" />\n\t\t\t</SliceSimulator>\n\t\t</template>\n\n\t\t<script ${scriptAttributes.join(\" \")}>\n\t\timport { SliceSimulator } from \"@slicemachine/adapter-nuxt/simulator\";\n\t\timport { components } from \"~/slices\";\n\t\t</script>\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst moveOrDeleteAppVue = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst filenameAppVue = await buildSrcPath({ filename: \"app.vue\", helpers });\n\n\t// If there's no `app.vue`, there's nothing to do.\n\tif (!(await checkHasProjectFile({ filename: filenameAppVue, helpers }))) {\n\t\treturn;\n\t}\n\n\tconst filecontentAppVue = await readProjectFile({\n\t\tfilename: filenameAppVue,\n\t\thelpers,\n\t\tencoding: \"utf-8\",\n\t});\n\n\t// We check for app.vue to contain Nuxt default welcome component to determine\n\t// if we need to consider it as the default one or not.\n\tif (!filecontentAppVue.includes(\"<NuxtWelcome\")) {\n\t\treturn;\n\t}\n\n\tconst filenameIndexVue = await buildSrcPath({\n\t\tfilename: path.join(\"pages/index.vue\"),\n\t\thelpers,\n\t});\n\n\t// If we don't have an `index.vue` we create one with the content of `app.vue`\n\tif (!(await checkHasProjectFile({ filename: filenameIndexVue, helpers }))) {\n\t\tawait writeProjectFile({\n\t\t\tfilename: filenameIndexVue,\n\t\t\tcontents: filecontentAppVue,\n\t\t\tformat: options.format,\n\t\t\thelpers,\n\t\t});\n\t}\n\n\t// Delete `app.vue`\n\tawait deleteProjectFile({\n\t\tfilename: filenameAppVue,\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppDirectory = await checkHasProjectFile({\n\t\tfilename: \"app\",\n\t\thelpers,\n\t});\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:3000/slice-simulator\";\n\n\t// Nest the default Slice Library in the `app` or `src` directory if it\n\t// exists and is empty.\n\tif (\n\t\t(hasAppDirectory || hasSrcDirectory) &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = hasAppDirectory\n\t\t\t\t? [\"./app/slices\"]\n\t\t\t\t: [\"./src/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tconfigurePrismicModule(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tmoveOrDeleteAppVue(context),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t]),\n\t);\n};\n"],"names":["installDependencies","_a"],"mappings":";;;;;;;;;;AAAA,IAAA;AAqBA,MAAM,eAAe;AAMrB,MAAM,sBAAsB,OAAO,EAClC,qBAAAA,2BAC6B;AAC7B,QAAMA,qBAAoB;AAAA,IACzB,cAAc;AAAA,MACb,CAAC,YAAY,GAAG;AAAA,IAChB;AAAA,IACD,KAAK;AAAA,EAAA,CACL;AACF;AAIA,MAAM,yBAAyB,OAAO,EACrC,cACgC;AAChC,MAAI,qBAAqB;AAErB,MAAA,CAAE,MAAM,oBAAoB,EAAE,UAAU,oBAAoB,QAAA,CAAS,GAAI;AACvD,yBAAA;AAIpB,QAAA,CAAE,MAAM,oBAAoB,EAAE,UAAU,oBAAoB,QAAA,CAAS,GACpE;AACD;AAAA,IACA;AAAA,EACD;AAEK,QAAA,iBAAiB,QAAQ,iBAAiB,kBAAkB;AAE5D,QAAA,MAAM,MAAM,SAAS,cAAc;AACzC,QAAM,SACL,IAAI,QAAQ,QAAQ,UAAU,kBAC3B,IAAI,QAAQ,QAAQ,MAAM,CAAC,IAC3B,IAAI,QAAQ;AAGhB,MAAI,0BAA0B;AAC9B,QAAM,8BAA8B,OAAO,WAAW,CAAA,GAAI,KACzD,CAAC,iBAA4C;AACxC,QAAA,OAAO,iBAAiB,UAAU;AACrC,aAAO,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CAAC,cAAc;AAAA,IAClB;AAAA,EACD;AAEK,QAAA,QAAQ,yBAAyB,QAAQ,QAAQ;AAAA,IACtD,QAAQ,QAAQ;AAAA,EAAA,CAChB;AACF;AAEO,MAAM,cAA8C,OAC1D,EAAE,qBAAqB,qBAAA,GACvB,YACG;AAEF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,oBAAoB,EAAE,qBAAqB,sBAAsB;AAAA,IACjE,uBAAuB,OAAO;AAAA,IAC9B,yBAAyB,OAAO;AAAA,IAChC,mBAAmB,OAAO;AAAA,IAC1B,yBAAyB,OAAO;AAAA,EAChC,CAAA,CAAC;AAEJ;"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const path = require("node:path");
4
+ const fs = require("@slicemachine/plugin-kit/fs");
5
+ function _interopNamespaceDefault(e) {
6
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
+ if (e) {
8
+ for (const k in e) {
9
+ if (k !== "default") {
10
+ const d = Object.getOwnPropertyDescriptor(e, k);
11
+ Object.defineProperty(n, k, d.get ? d : {
12
+ enumerable: true,
13
+ get: () => e[k]
14
+ });
15
+ }
16
+ }
17
+ }
18
+ n.default = e;
19
+ return Object.freeze(n);
20
+ }
21
+ const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
22
+ async function buildSrcPath(args) {
23
+ const hasAppDirectory = await fs.checkHasProjectFile({
24
+ filename: "app",
25
+ helpers: args.helpers
26
+ });
27
+ if (hasAppDirectory) {
28
+ return path__namespace.join("app", args.filename);
29
+ }
30
+ const hasSrcDirectory = await fs.checkHasProjectFile({
31
+ filename: "src",
32
+ helpers: args.helpers
33
+ });
34
+ if (hasSrcDirectory) {
35
+ return path__namespace.join("src", args.filename);
36
+ }
37
+ return args.filename;
38
+ }
39
+ exports.buildSrcPath = buildSrcPath;
40
+ //# sourceMappingURL=buildSrcPath.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildSrcPath.cjs","sources":["../../../src/lib/buildSrcPath.ts"],"sourcesContent":["// TODO: If Nuxt provides a way to read `nuxt.config.js`'s `srcDir` value, we\n// can use the exact value given. The current implementation does not support\n// custom values different than \"app\" or \"src\".\n\nimport * as path from \"node:path\";\n\nimport { SliceMachineHelpers } from \"@slicemachine/plugin-kit\";\nimport { checkHasProjectFile } from \"@slicemachine/plugin-kit/fs\";\n\nexport async function buildSrcPath(args: {\n\tfilename: string;\n\thelpers: SliceMachineHelpers;\n}): Promise<string> {\n\tconst hasAppDirectory = await checkHasProjectFile({\n\t\tfilename: \"app\",\n\t\thelpers: args.helpers,\n\t});\n\tif (hasAppDirectory) {\n\t\treturn path.join(\"app\", args.filename);\n\t}\n\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers: args.helpers,\n\t});\n\tif (hasSrcDirectory) {\n\t\treturn path.join(\"src\", args.filename);\n\t}\n\n\treturn args.filename;\n}\n"],"names":["checkHasProjectFile","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;AASA,eAAsB,aAAa,MAGlC;AACM,QAAA,kBAAkB,MAAMA,uBAAoB;AAAA,IACjD,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AACD,MAAI,iBAAiB;AACpB,WAAOC,gBAAK,KAAK,OAAO,KAAK,QAAQ;AAAA,EACrC;AAEK,QAAA,kBAAkB,MAAMD,uBAAoB;AAAA,IACjD,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AACD,MAAI,iBAAiB;AACpB,WAAOC,gBAAK,KAAK,OAAO,KAAK,QAAQ;AAAA,EACrC;AAED,SAAO,KAAK;AACb;;"}
@@ -0,0 +1,5 @@
1
+ import { SliceMachineHelpers } from "@slicemachine/plugin-kit";
2
+ export declare function buildSrcPath(args: {
3
+ filename: string;
4
+ helpers: SliceMachineHelpers;
5
+ }): Promise<string>;
@@ -0,0 +1,23 @@
1
+ import * as path from "node:path";
2
+ import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs";
3
+ async function buildSrcPath(args) {
4
+ const hasAppDirectory = await checkHasProjectFile({
5
+ filename: "app",
6
+ helpers: args.helpers
7
+ });
8
+ if (hasAppDirectory) {
9
+ return path.join("app", args.filename);
10
+ }
11
+ const hasSrcDirectory = await checkHasProjectFile({
12
+ filename: "src",
13
+ helpers: args.helpers
14
+ });
15
+ if (hasSrcDirectory) {
16
+ return path.join("src", args.filename);
17
+ }
18
+ return args.filename;
19
+ }
20
+ export {
21
+ buildSrcPath
22
+ };
23
+ //# sourceMappingURL=buildSrcPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildSrcPath.js","sources":["../../../src/lib/buildSrcPath.ts"],"sourcesContent":["// TODO: If Nuxt provides a way to read `nuxt.config.js`'s `srcDir` value, we\n// can use the exact value given. The current implementation does not support\n// custom values different than \"app\" or \"src\".\n\nimport * as path from \"node:path\";\n\nimport { SliceMachineHelpers } from \"@slicemachine/plugin-kit\";\nimport { checkHasProjectFile } from \"@slicemachine/plugin-kit/fs\";\n\nexport async function buildSrcPath(args: {\n\tfilename: string;\n\thelpers: SliceMachineHelpers;\n}): Promise<string> {\n\tconst hasAppDirectory = await checkHasProjectFile({\n\t\tfilename: \"app\",\n\t\thelpers: args.helpers,\n\t});\n\tif (hasAppDirectory) {\n\t\treturn path.join(\"app\", args.filename);\n\t}\n\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers: args.helpers,\n\t});\n\tif (hasSrcDirectory) {\n\t\treturn path.join(\"src\", args.filename);\n\t}\n\n\treturn args.filename;\n}\n"],"names":[],"mappings":";;AASA,eAAsB,aAAa,MAGlC;AACM,QAAA,kBAAkB,MAAM,oBAAoB;AAAA,IACjD,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AACD,MAAI,iBAAiB;AACpB,WAAO,KAAK,KAAK,OAAO,KAAK,QAAQ;AAAA,EACrC;AAEK,QAAA,kBAAkB,MAAM,oBAAoB;AAAA,IACjD,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AACD,MAAI,iBAAiB;AACpB,WAAO,KAAK,KAAK,OAAO,KAAK,QAAQ;AAAA,EACrC;AAED,SAAO,KAAK;AACb;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-nuxt",
3
- "version": "0.3.42-alpha.aa-sort-default-page-fields.1",
3
+ "version": "0.3.42-alpha.aa-support-nuxt-4.1",
4
4
  "description": "Slice Machine adapter for Nuxt 3.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -61,7 +61,7 @@
61
61
  "dependencies": {
62
62
  "@prismicio/simulator": "^0.1.4",
63
63
  "@prismicio/types-internal": "^2.4.1",
64
- "@slicemachine/plugin-kit": "0.4.42-alpha.aa-sort-default-page-fields.1",
64
+ "@slicemachine/plugin-kit": "0.4.42-alpha.aa-support-nuxt-4.1",
65
65
  "common-tags": "^1.8.2",
66
66
  "fp-ts": "^2.13.1",
67
67
  "io-ts": "^2.2.20",
@@ -13,9 +13,9 @@ import {
13
13
  import { stripIndent } from "common-tags";
14
14
  import { builders, loadFile, writeFile } from "magicast";
15
15
 
16
+ import { buildSrcPath } from "../lib/buildSrcPath";
16
17
  import { rejectIfNecessary } from "../lib/rejectIfNecessary";
17
18
  import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
18
- import { checkHasSrcDirectory } from "../lib/checkHasSrcDirectory";
19
19
 
20
20
  import type { PluginOptions } from "../types";
21
21
 
@@ -28,23 +28,12 @@ type InstallDependenciesArgs = {
28
28
  const installDependencies = async ({
29
29
  installDependencies,
30
30
  }: InstallDependenciesArgs) => {
31
- try {
32
- await installDependencies({
33
- dependencies: {
34
- [NUXT_PRISMIC]: "^3.0.0",
35
- },
36
- dev: true,
37
- });
38
- } catch (error) {
39
- // TODO: Remove when latest is published and documented
40
- // Fallback to RC if latest is still not available
41
- await installDependencies({
42
- dependencies: {
43
- [NUXT_PRISMIC]: "rc",
44
- },
45
- dev: true,
46
- });
47
- }
31
+ await installDependencies({
32
+ dependencies: {
33
+ [NUXT_PRISMIC]: "^3.3.0",
34
+ },
35
+ dev: true,
36
+ });
48
37
  };
49
38
 
50
39
  type ConfigurePrismicModuleArgs = SliceMachineContext<PluginOptions>;
@@ -125,16 +114,11 @@ const createSliceSimulatorPage = async ({
125
114
  options,
126
115
  });
127
116
 
128
- const srcPagesDirectoryExists = await checkHasProjectFile({
129
- filename: "src/pages",
117
+ const filename = await buildSrcPath({
118
+ filename: path.join("pages", "slice-simulator.vue"),
130
119
  helpers,
131
120
  });
132
121
 
133
- const filename = path.join(
134
- srcPagesDirectoryExists ? "src/pages" : "pages",
135
- "slice-simulator.vue",
136
- );
137
-
138
122
  if (await checkHasProjectFile({ filename, helpers })) {
139
123
  return;
140
124
  }
@@ -169,14 +153,9 @@ const moveOrDeleteAppVue = async ({
169
153
  helpers,
170
154
  options,
171
155
  }: CreateSliceSimulatorPageArgs) => {
172
- const srcDirectoryExists = await checkHasProjectFile({
173
- filename: "src",
174
- helpers,
175
- });
176
-
177
- const filenameAppVue = path.join(srcDirectoryExists ? "src" : "", "app.vue");
156
+ const filenameAppVue = await buildSrcPath({ filename: "app.vue", helpers });
178
157
 
179
- // If there's not `app.vue`, there's nothing to do.
158
+ // If there's no `app.vue`, there's nothing to do.
180
159
  if (!(await checkHasProjectFile({ filename: filenameAppVue, helpers }))) {
181
160
  return;
182
161
  }
@@ -187,21 +166,17 @@ const moveOrDeleteAppVue = async ({
187
166
  encoding: "utf-8",
188
167
  });
189
168
 
190
- // We check for app.vue to contain Nuxt default welcome component to determine if we need to consider it as the default one or not.
169
+ // We check for app.vue to contain Nuxt default welcome component to determine
170
+ // if we need to consider it as the default one or not.
191
171
  if (!filecontentAppVue.includes("<NuxtWelcome")) {
192
172
  return;
193
173
  }
194
174
 
195
- const srcPagesDirectoryExists = await checkHasProjectFile({
196
- filename: "src/pages",
175
+ const filenameIndexVue = await buildSrcPath({
176
+ filename: path.join("pages/index.vue"),
197
177
  helpers,
198
178
  });
199
179
 
200
- const filenameIndexVue = path.join(
201
- srcPagesDirectoryExists ? "src/pages" : "pages",
202
- "index.vue",
203
- );
204
-
205
180
  // If we don't have an `index.vue` we create one with the content of `app.vue`
206
181
  if (!(await checkHasProjectFile({ filename: filenameIndexVue, helpers }))) {
207
182
  await writeProjectFile({
@@ -224,17 +199,24 @@ const modifySliceMachineConfig = async ({
224
199
  options,
225
200
  actions,
226
201
  }: SliceMachineContext<PluginOptions>) => {
227
- const hasSrcDirectory = await checkHasSrcDirectory({ helpers });
202
+ const hasAppDirectory = await checkHasProjectFile({
203
+ filename: "app",
204
+ helpers,
205
+ });
206
+ const hasSrcDirectory = await checkHasProjectFile({
207
+ filename: "src",
208
+ helpers,
209
+ });
228
210
  const project = await helpers.getProject();
229
211
 
230
212
  // Add Slice Simulator URL.
231
213
  project.config.localSliceSimulatorURL ||=
232
214
  "http://localhost:3000/slice-simulator";
233
215
 
234
- // Nest the default Slice Library in the src directory if it exists and
235
- // is empty.
216
+ // Nest the default Slice Library in the `app` or `src` directory if it
217
+ // exists and is empty.
236
218
  if (
237
- hasSrcDirectory &&
219
+ (hasAppDirectory || hasSrcDirectory) &&
238
220
  project.config.libraries &&
239
221
  JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])
240
222
  ) {
@@ -243,7 +225,9 @@ const modifySliceMachineConfig = async ({
243
225
  });
244
226
 
245
227
  if (sliceLibrary.sliceIDs.length < 1) {
246
- project.config.libraries = ["./src/slices"];
228
+ project.config.libraries = hasAppDirectory
229
+ ? ["./app/slices"]
230
+ : ["./src/slices"];
247
231
  }
248
232
  }
249
233
 
@@ -0,0 +1,31 @@
1
+ // TODO: If Nuxt provides a way to read `nuxt.config.js`'s `srcDir` value, we
2
+ // can use the exact value given. The current implementation does not support
3
+ // custom values different than "app" or "src".
4
+
5
+ import * as path from "node:path";
6
+
7
+ import { SliceMachineHelpers } from "@slicemachine/plugin-kit";
8
+ import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs";
9
+
10
+ export async function buildSrcPath(args: {
11
+ filename: string;
12
+ helpers: SliceMachineHelpers;
13
+ }): Promise<string> {
14
+ const hasAppDirectory = await checkHasProjectFile({
15
+ filename: "app",
16
+ helpers: args.helpers,
17
+ });
18
+ if (hasAppDirectory) {
19
+ return path.join("app", args.filename);
20
+ }
21
+
22
+ const hasSrcDirectory = await checkHasProjectFile({
23
+ filename: "src",
24
+ helpers: args.helpers,
25
+ });
26
+ if (hasSrcDirectory) {
27
+ return path.join("src", args.filename);
28
+ }
29
+
30
+ return args.filename;
31
+ }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("@slicemachine/plugin-kit/fs");
4
- async function checkHasSrcDirectory(args) {
5
- return await fs.checkHasProjectFile({
6
- filename: "src",
7
- helpers: args.helpers
8
- });
9
- }
10
- exports.checkHasSrcDirectory = checkHasSrcDirectory;
11
- //# sourceMappingURL=checkHasSrcDirectory.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkHasSrcDirectory.cjs","sources":["../../../src/lib/checkHasSrcDirectory.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { checkHasProjectFile } from \"@slicemachine/plugin-kit/fs\";\n\nimport { PluginOptions } from \"../types\";\n\ntype CheckHasSrcDirectoryArgs = Pick<\n\tSliceMachineContext<PluginOptions>,\n\t\"helpers\"\n>;\n\nexport async function checkHasSrcDirectory(\n\targs: CheckHasSrcDirectoryArgs,\n): Promise<boolean> {\n\treturn await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers: args.helpers,\n\t});\n}\n"],"names":["checkHasProjectFile"],"mappings":";;;AAUA,eAAsB,qBACrB,MAA8B;AAE9B,SAAO,MAAMA,GAAAA,oBAAoB;AAAA,IAChC,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AACF;;"}
@@ -1,5 +0,0 @@
1
- import { SliceMachineContext } from "@slicemachine/plugin-kit";
2
- import { PluginOptions } from "../types";
3
- type CheckHasSrcDirectoryArgs = Pick<SliceMachineContext<PluginOptions>, "helpers">;
4
- export declare function checkHasSrcDirectory(args: CheckHasSrcDirectoryArgs): Promise<boolean>;
5
- export {};
@@ -1,11 +0,0 @@
1
- import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs";
2
- async function checkHasSrcDirectory(args) {
3
- return await checkHasProjectFile({
4
- filename: "src",
5
- helpers: args.helpers
6
- });
7
- }
8
- export {
9
- checkHasSrcDirectory
10
- };
11
- //# sourceMappingURL=checkHasSrcDirectory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkHasSrcDirectory.js","sources":["../../../src/lib/checkHasSrcDirectory.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { checkHasProjectFile } from \"@slicemachine/plugin-kit/fs\";\n\nimport { PluginOptions } from \"../types\";\n\ntype CheckHasSrcDirectoryArgs = Pick<\n\tSliceMachineContext<PluginOptions>,\n\t\"helpers\"\n>;\n\nexport async function checkHasSrcDirectory(\n\targs: CheckHasSrcDirectoryArgs,\n): Promise<boolean> {\n\treturn await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers: args.helpers,\n\t});\n}\n"],"names":[],"mappings":";AAUA,eAAsB,qBACrB,MAA8B;AAE9B,SAAO,MAAM,oBAAoB;AAAA,IAChC,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AACF;"}
@@ -1,18 +0,0 @@
1
- import { SliceMachineContext } from "@slicemachine/plugin-kit";
2
- import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs";
3
-
4
- import { PluginOptions } from "../types";
5
-
6
- type CheckHasSrcDirectoryArgs = Pick<
7
- SliceMachineContext<PluginOptions>,
8
- "helpers"
9
- >;
10
-
11
- export async function checkHasSrcDirectory(
12
- args: CheckHasSrcDirectoryArgs,
13
- ): Promise<boolean> {
14
- return await checkHasProjectFile({
15
- filename: "src",
16
- helpers: args.helpers,
17
- });
18
- }