@slicemachine/adapter-nuxt 0.3.42-alpha.aa-support-nuxt-4.1 → 0.3.42-alpha.aa-contributing.4

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");
8
7
  const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
9
8
  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,12 +30,21 @@ 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
- await installDependencies2({
34
- dependencies: {
35
- [NUXT_PRISMIC]: "^3.3.0"
36
- },
37
- dev: true
38
- });
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
+ }
39
48
  };
40
49
  const configurePrismicModule = async ({ helpers }) => {
41
50
  let nuxtConfigFilename = "nuxt.config.js";
@@ -81,10 +90,11 @@ const createSliceSimulatorPage = async ({ helpers, options }) => {
81
90
  helpers,
82
91
  options
83
92
  });
84
- const filename = await buildSrcPath.buildSrcPath({
85
- filename: path__namespace.join("pages", "slice-simulator.vue"),
93
+ const srcPagesDirectoryExists = await fs.checkHasProjectFile({
94
+ filename: "src/pages",
86
95
  helpers
87
96
  });
97
+ const filename = path__namespace.join(srcPagesDirectoryExists ? "src/pages" : "pages", "slice-simulator.vue");
88
98
  if (await fs.checkHasProjectFile({ filename, helpers })) {
89
99
  return;
90
100
  }
@@ -101,7 +111,11 @@ const createSliceSimulatorPage = async ({ helpers, options }) => {
101
111
  });
102
112
  };
103
113
  const moveOrDeleteAppVue = async ({ helpers, options }) => {
104
- const filenameAppVue = await buildSrcPath.buildSrcPath({ filename: "app.vue", helpers });
114
+ const srcDirectoryExists = await fs.checkHasProjectFile({
115
+ filename: "src",
116
+ helpers
117
+ });
118
+ const filenameAppVue = path__namespace.join(srcDirectoryExists ? "src" : "", "app.vue");
105
119
  if (!await fs.checkHasProjectFile({ filename: filenameAppVue, helpers })) {
106
120
  return;
107
121
  }
@@ -113,10 +127,11 @@ const moveOrDeleteAppVue = async ({ helpers, options }) => {
113
127
  if (!filecontentAppVue.includes("<NuxtWelcome")) {
114
128
  return;
115
129
  }
116
- const filenameIndexVue = await buildSrcPath.buildSrcPath({
117
- filename: path__namespace.join("pages/index.vue"),
130
+ const srcPagesDirectoryExists = await fs.checkHasProjectFile({
131
+ filename: "src/pages",
118
132
  helpers
119
133
  });
134
+ const filenameIndexVue = path__namespace.join(srcPagesDirectoryExists ? "src/pages" : "pages", "index.vue");
120
135
  if (!await fs.checkHasProjectFile({ filename: filenameIndexVue, helpers })) {
121
136
  await fs.writeProjectFile({
122
137
  filename: filenameIndexVue,
@@ -132,22 +147,15 @@ const moveOrDeleteAppVue = async ({ helpers, options }) => {
132
147
  };
133
148
  const modifySliceMachineConfig = async ({ helpers, options, actions }) => {
134
149
  var _a2;
135
- const hasAppDirectory = await fs.checkHasProjectFile({
136
- filename: "app",
137
- helpers
138
- });
139
- const hasSrcDirectory = await fs.checkHasProjectFile({
140
- filename: "src",
141
- helpers
142
- });
150
+ const hasSrcDirectory = await checkHasSrcDirectory.checkHasSrcDirectory({ helpers });
143
151
  const project = await helpers.getProject();
144
152
  (_a2 = project.config).localSliceSimulatorURL || (_a2.localSliceSimulatorURL = "http://localhost:3000/slice-simulator");
145
- if ((hasAppDirectory || hasSrcDirectory) && project.config.libraries && JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])) {
153
+ if (hasSrcDirectory && project.config.libraries && JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])) {
146
154
  const sliceLibrary = await actions.readSliceLibrary({
147
155
  libraryID: project.config.libraries[0]
148
156
  });
149
157
  if (sliceLibrary.sliceIDs.length < 1) {
150
- project.config.libraries = hasAppDirectory ? ["./app/slices"] : ["./src/slices"];
158
+ project.config.libraries = ["./src/slices"];
151
159
  }
152
160
  }
153
161
  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 { 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,CAAA,GAAI,KACzD,CAAC,iBAA4C;AACxC,QAAA,OAAO,iBAAiB,UAAU;AACrC,aAAO,iBAAiB;AAAA,IACd,WAAA,MAAM,QAAQ,YAAY,GAAG;AACb,gCAAA,CAAC,CAAC,aAAa,CAAC;AAEnC,aAAA,aAAa,CAAC,MAAM;AAAA,IAC3B;AAEM,WAAA;AAAA,EAAA,CACP;AAGF,MAAI,CAAC,4BAA4B;AAChC,WAAO,YA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AAM,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 { 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;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,iBA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AM,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;;"}
@@ -2,21 +2,30 @@ 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";
6
5
  import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
7
6
  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
- await installDependencies2({
15
- dependencies: {
16
- [NUXT_PRISMIC]: "^3.3.0"
17
- },
18
- dev: true
19
- });
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
+ }
20
29
  };
21
30
  const configurePrismicModule = async ({ helpers }) => {
22
31
  let nuxtConfigFilename = "nuxt.config.js";
@@ -62,10 +71,11 @@ const createSliceSimulatorPage = async ({ helpers, options }) => {
62
71
  helpers,
63
72
  options
64
73
  });
65
- const filename = await buildSrcPath({
66
- filename: path.join("pages", "slice-simulator.vue"),
74
+ const srcPagesDirectoryExists = await checkHasProjectFile({
75
+ filename: "src/pages",
67
76
  helpers
68
77
  });
78
+ const filename = path.join(srcPagesDirectoryExists ? "src/pages" : "pages", "slice-simulator.vue");
69
79
  if (await checkHasProjectFile({ filename, helpers })) {
70
80
  return;
71
81
  }
@@ -82,7 +92,11 @@ const createSliceSimulatorPage = async ({ helpers, options }) => {
82
92
  });
83
93
  };
84
94
  const moveOrDeleteAppVue = async ({ helpers, options }) => {
85
- const filenameAppVue = await buildSrcPath({ filename: "app.vue", helpers });
95
+ const srcDirectoryExists = await checkHasProjectFile({
96
+ filename: "src",
97
+ helpers
98
+ });
99
+ const filenameAppVue = path.join(srcDirectoryExists ? "src" : "", "app.vue");
86
100
  if (!await checkHasProjectFile({ filename: filenameAppVue, helpers })) {
87
101
  return;
88
102
  }
@@ -94,10 +108,11 @@ const moveOrDeleteAppVue = async ({ helpers, options }) => {
94
108
  if (!filecontentAppVue.includes("<NuxtWelcome")) {
95
109
  return;
96
110
  }
97
- const filenameIndexVue = await buildSrcPath({
98
- filename: path.join("pages/index.vue"),
111
+ const srcPagesDirectoryExists = await checkHasProjectFile({
112
+ filename: "src/pages",
99
113
  helpers
100
114
  });
115
+ const filenameIndexVue = path.join(srcPagesDirectoryExists ? "src/pages" : "pages", "index.vue");
101
116
  if (!await checkHasProjectFile({ filename: filenameIndexVue, helpers })) {
102
117
  await writeProjectFile({
103
118
  filename: filenameIndexVue,
@@ -113,22 +128,15 @@ const moveOrDeleteAppVue = async ({ helpers, options }) => {
113
128
  };
114
129
  const modifySliceMachineConfig = async ({ helpers, options, actions }) => {
115
130
  var _a2;
116
- const hasAppDirectory = await checkHasProjectFile({
117
- filename: "app",
118
- helpers
119
- });
120
- const hasSrcDirectory = await checkHasProjectFile({
121
- filename: "src",
122
- helpers
123
- });
131
+ const hasSrcDirectory = await checkHasSrcDirectory({ helpers });
124
132
  const project = await helpers.getProject();
125
133
  (_a2 = project.config).localSliceSimulatorURL || (_a2.localSliceSimulatorURL = "http://localhost:3000/slice-simulator");
126
- if ((hasAppDirectory || hasSrcDirectory) && project.config.libraries && JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])) {
134
+ if (hasSrcDirectory && project.config.libraries && JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])) {
127
135
  const sliceLibrary = await actions.readSliceLibrary({
128
136
  libraryID: project.config.libraries[0]
129
137
  });
130
138
  if (sliceLibrary.sliceIDs.length < 1) {
131
- project.config.libraries = hasAppDirectory ? ["./app/slices"] : ["./src/slices"];
139
+ project.config.libraries = ["./src/slices"];
132
140
  }
133
141
  }
134
142
  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 { 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,iBAAiB;AAAA,IACd,WAAA,MAAM,QAAQ,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K,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 { 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,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,iBAAiB;AA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AAO,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;"}
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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;;"}
@@ -0,0 +1,5 @@
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 {};
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-nuxt",
3
- "version": "0.3.42-alpha.aa-support-nuxt-4.1",
3
+ "version": "0.3.42-alpha.aa-contributing.4",
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-support-nuxt-4.1",
64
+ "@slicemachine/plugin-kit": "0.4.42-alpha.aa-contributing.4",
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";
17
16
  import { rejectIfNecessary } from "../lib/rejectIfNecessary";
18
17
  import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
18
+ import { checkHasSrcDirectory } from "../lib/checkHasSrcDirectory";
19
19
 
20
20
  import type { PluginOptions } from "../types";
21
21
 
@@ -28,12 +28,23 @@ type InstallDependenciesArgs = {
28
28
  const installDependencies = async ({
29
29
  installDependencies,
30
30
  }: InstallDependenciesArgs) => {
31
- await installDependencies({
32
- dependencies: {
33
- [NUXT_PRISMIC]: "^3.3.0",
34
- },
35
- dev: true,
36
- });
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
+ }
37
48
  };
38
49
 
39
50
  type ConfigurePrismicModuleArgs = SliceMachineContext<PluginOptions>;
@@ -114,11 +125,16 @@ const createSliceSimulatorPage = async ({
114
125
  options,
115
126
  });
116
127
 
117
- const filename = await buildSrcPath({
118
- filename: path.join("pages", "slice-simulator.vue"),
128
+ const srcPagesDirectoryExists = await checkHasProjectFile({
129
+ filename: "src/pages",
119
130
  helpers,
120
131
  });
121
132
 
133
+ const filename = path.join(
134
+ srcPagesDirectoryExists ? "src/pages" : "pages",
135
+ "slice-simulator.vue",
136
+ );
137
+
122
138
  if (await checkHasProjectFile({ filename, helpers })) {
123
139
  return;
124
140
  }
@@ -153,9 +169,14 @@ const moveOrDeleteAppVue = async ({
153
169
  helpers,
154
170
  options,
155
171
  }: CreateSliceSimulatorPageArgs) => {
156
- const filenameAppVue = await buildSrcPath({ filename: "app.vue", helpers });
172
+ const srcDirectoryExists = await checkHasProjectFile({
173
+ filename: "src",
174
+ helpers,
175
+ });
176
+
177
+ const filenameAppVue = path.join(srcDirectoryExists ? "src" : "", "app.vue");
157
178
 
158
- // If there's no `app.vue`, there's nothing to do.
179
+ // If there's not `app.vue`, there's nothing to do.
159
180
  if (!(await checkHasProjectFile({ filename: filenameAppVue, helpers }))) {
160
181
  return;
161
182
  }
@@ -166,17 +187,21 @@ const moveOrDeleteAppVue = async ({
166
187
  encoding: "utf-8",
167
188
  });
168
189
 
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.
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.
171
191
  if (!filecontentAppVue.includes("<NuxtWelcome")) {
172
192
  return;
173
193
  }
174
194
 
175
- const filenameIndexVue = await buildSrcPath({
176
- filename: path.join("pages/index.vue"),
195
+ const srcPagesDirectoryExists = await checkHasProjectFile({
196
+ filename: "src/pages",
177
197
  helpers,
178
198
  });
179
199
 
200
+ const filenameIndexVue = path.join(
201
+ srcPagesDirectoryExists ? "src/pages" : "pages",
202
+ "index.vue",
203
+ );
204
+
180
205
  // If we don't have an `index.vue` we create one with the content of `app.vue`
181
206
  if (!(await checkHasProjectFile({ filename: filenameIndexVue, helpers }))) {
182
207
  await writeProjectFile({
@@ -199,24 +224,17 @@ const modifySliceMachineConfig = async ({
199
224
  options,
200
225
  actions,
201
226
  }: SliceMachineContext<PluginOptions>) => {
202
- const hasAppDirectory = await checkHasProjectFile({
203
- filename: "app",
204
- helpers,
205
- });
206
- const hasSrcDirectory = await checkHasProjectFile({
207
- filename: "src",
208
- helpers,
209
- });
227
+ const hasSrcDirectory = await checkHasSrcDirectory({ helpers });
210
228
  const project = await helpers.getProject();
211
229
 
212
230
  // Add Slice Simulator URL.
213
231
  project.config.localSliceSimulatorURL ||=
214
232
  "http://localhost:3000/slice-simulator";
215
233
 
216
- // Nest the default Slice Library in the `app` or `src` directory if it
217
- // exists and is empty.
234
+ // Nest the default Slice Library in the src directory if it exists and
235
+ // is empty.
218
236
  if (
219
- (hasAppDirectory || hasSrcDirectory) &&
237
+ hasSrcDirectory &&
220
238
  project.config.libraries &&
221
239
  JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])
222
240
  ) {
@@ -225,9 +243,7 @@ const modifySliceMachineConfig = async ({
225
243
  });
226
244
 
227
245
  if (sliceLibrary.sliceIDs.length < 1) {
228
- project.config.libraries = hasAppDirectory
229
- ? ["./app/slices"]
230
- : ["./src/slices"];
246
+ project.config.libraries = ["./src/slices"];
231
247
  }
232
248
  }
233
249
 
@@ -0,0 +1,18 @@
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
+ }
@@ -1,40 +0,0 @@
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
@@ -1 +0,0 @@
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;;"}
@@ -1,5 +0,0 @@
1
- import { SliceMachineHelpers } from "@slicemachine/plugin-kit";
2
- export declare function buildSrcPath(args: {
3
- filename: string;
4
- helpers: SliceMachineHelpers;
5
- }): Promise<string>;
@@ -1,23 +0,0 @@
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
@@ -1 +0,0 @@
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;"}
@@ -1,31 +0,0 @@
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
- }