@sanity/cli 6.0.0-alpha.3 → 6.0.0-alpha.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.
Files changed (110) hide show
  1. package/dist/actions/auth/login/{index.js → login.js} +1 -1
  2. package/dist/actions/auth/login/{index.js.map → login.js.map} +1 -1
  3. package/dist/actions/organizations/getOrganizationChoices.d.ts +6 -0
  4. package/dist/actions/organizations/getOrganizationChoices.js +23 -0
  5. package/dist/actions/organizations/getOrganizationChoices.js.map +1 -0
  6. package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.d.ts +2 -0
  7. package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.js +9 -0
  8. package/dist/actions/organizations/getOrganizationsWithAttachGrantInfo.js.map +1 -0
  9. package/dist/actions/organizations/hasProjectAttachGrant.d.ts +1 -0
  10. package/dist/actions/organizations/hasProjectAttachGrant.js +24 -0
  11. package/dist/actions/organizations/hasProjectAttachGrant.js.map +1 -0
  12. package/dist/actions/schema/utils/schemaStoreValidation.js +2 -2
  13. package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
  14. package/dist/commands/__tests__/init/init.authentication.test.js +60 -0
  15. package/dist/commands/__tests__/init/init.authentication.test.js.map +1 -0
  16. package/dist/commands/__tests__/init/init.create-new-project.test.js +196 -0
  17. package/dist/commands/__tests__/init/init.create-new-project.test.js.map +1 -0
  18. package/dist/commands/__tests__/init/init.plan.test.js +220 -0
  19. package/dist/commands/__tests__/init/init.plan.test.js.map +1 -0
  20. package/dist/commands/__tests__/init/init.setup.test.js +279 -0
  21. package/dist/commands/__tests__/init/init.setup.test.js.map +1 -0
  22. package/dist/commands/__tests__/migration.test.js +119 -0
  23. package/dist/commands/__tests__/migration.test.js.map +1 -0
  24. package/dist/commands/backup/__tests__/download.test.js +3 -3
  25. package/dist/commands/backup/__tests__/download.test.js.map +1 -1
  26. package/dist/commands/dataset/__tests__/import.test.js +2 -2
  27. package/dist/commands/dataset/__tests__/import.test.js.map +1 -1
  28. package/dist/commands/documents/__tests__/query.test.js +3 -3
  29. package/dist/commands/documents/__tests__/query.test.js.map +1 -1
  30. package/dist/commands/init.d.ts +4 -0
  31. package/dist/commands/init.js +151 -18
  32. package/dist/commands/init.js.map +1 -1
  33. package/dist/commands/login.js +1 -1
  34. package/dist/commands/login.js.map +1 -1
  35. package/dist/services/organizations.d.ts +40 -0
  36. package/dist/services/organizations.js +41 -0
  37. package/dist/services/organizations.js.map +1 -0
  38. package/dist/services/projects.d.ts +20 -0
  39. package/dist/services/projects.js +30 -1
  40. package/dist/services/projects.js.map +1 -1
  41. package/dist/services/user.d.ts +2 -0
  42. package/dist/services/user.js +11 -0
  43. package/dist/services/user.js.map +1 -0
  44. package/oclif.config.js +6 -1
  45. package/oclif.manifest.json +33 -184
  46. package/package.json +7 -7
  47. package/dist/actions/migration/getMigrationRootDirectory.d.ts +0 -2
  48. package/dist/actions/migration/getMigrationRootDirectory.js +0 -14
  49. package/dist/actions/migration/getMigrationRootDirectory.js.map +0 -1
  50. package/dist/actions/migration/resolveMigrations.d.ts +0 -19
  51. package/dist/actions/migration/resolveMigrations.js +0 -43
  52. package/dist/actions/migration/resolveMigrations.js.map +0 -1
  53. package/dist/actions/migration/templates/__tests__/minimalAdvanced.test.js +0 -65
  54. package/dist/actions/migration/templates/__tests__/minimalAdvanced.test.js.map +0 -1
  55. package/dist/actions/migration/templates/__tests__/minimalSimple.test.js +0 -145
  56. package/dist/actions/migration/templates/__tests__/minimalSimple.test.js.map +0 -1
  57. package/dist/actions/migration/templates/__tests__/renameField.test.js +0 -63
  58. package/dist/actions/migration/templates/__tests__/renameField.test.js.map +0 -1
  59. package/dist/actions/migration/templates/__tests__/renameType.test.js +0 -61
  60. package/dist/actions/migration/templates/__tests__/renameType.test.js.map +0 -1
  61. package/dist/actions/migration/templates/__tests__/stringToPTE.test.js +0 -87
  62. package/dist/actions/migration/templates/__tests__/stringToPTE.test.js.map +0 -1
  63. package/dist/actions/migration/templates/index.d.ts +0 -5
  64. package/dist/actions/migration/templates/index.js +0 -7
  65. package/dist/actions/migration/templates/index.js.map +0 -1
  66. package/dist/actions/migration/templates/minimalAdvanced.d.ts +0 -4
  67. package/dist/actions/migration/templates/minimalAdvanced.js +0 -21
  68. package/dist/actions/migration/templates/minimalAdvanced.js.map +0 -1
  69. package/dist/actions/migration/templates/minimalSimple.d.ts +0 -4
  70. package/dist/actions/migration/templates/minimalSimple.js +0 -61
  71. package/dist/actions/migration/templates/minimalSimple.js.map +0 -1
  72. package/dist/actions/migration/templates/renameField.d.ts +0 -4
  73. package/dist/actions/migration/templates/renameField.js +0 -20
  74. package/dist/actions/migration/templates/renameField.js.map +0 -1
  75. package/dist/actions/migration/templates/renameType.d.ts +0 -4
  76. package/dist/actions/migration/templates/renameType.js +0 -19
  77. package/dist/actions/migration/templates/renameType.js.map +0 -1
  78. package/dist/actions/migration/templates/stringToPTE.d.ts +0 -4
  79. package/dist/actions/migration/templates/stringToPTE.js +0 -32
  80. package/dist/actions/migration/templates/stringToPTE.js.map +0 -1
  81. package/dist/commands/__tests__/init.test.js +0 -411
  82. package/dist/commands/__tests__/init.test.js.map +0 -1
  83. package/dist/commands/migration/__tests__/create.test.js +0 -296
  84. package/dist/commands/migration/__tests__/create.test.js.map +0 -1
  85. package/dist/commands/migration/__tests__/list.test.js +0 -166
  86. package/dist/commands/migration/__tests__/list.test.js.map +0 -1
  87. package/dist/commands/migration/__tests__/run.test.js +0 -481
  88. package/dist/commands/migration/__tests__/run.test.js.map +0 -1
  89. package/dist/commands/migration/create.d.ts +0 -17
  90. package/dist/commands/migration/create.js +0 -143
  91. package/dist/commands/migration/create.js.map +0 -1
  92. package/dist/commands/migration/list.d.ts +0 -9
  93. package/dist/commands/migration/list.js +0 -61
  94. package/dist/commands/migration/list.js.map +0 -1
  95. package/dist/commands/migration/run.d.ts +0 -26
  96. package/dist/commands/migration/run.js +0 -271
  97. package/dist/commands/migration/run.js.map +0 -1
  98. package/dist/util/migration/constants.d.ts +0 -3
  99. package/dist/util/migration/constants.js +0 -10
  100. package/dist/util/migration/constants.js.map +0 -1
  101. package/dist/util/migration/ensureApiVersionFormat.d.ts +0 -9
  102. package/dist/util/migration/ensureApiVersionFormat.js +0 -16
  103. package/dist/util/migration/ensureApiVersionFormat.js.map +0 -1
  104. package/dist/util/migration/prettyMutationFormatter.d.ts +0 -8
  105. package/dist/util/migration/prettyMutationFormatter.js +0 -141
  106. package/dist/util/migration/prettyMutationFormatter.js.map +0 -1
  107. package/dist/utils/migration/resolveMigrationScript.d.ts +0 -44
  108. package/dist/utils/migration/resolveMigrationScript.js +0 -74
  109. package/dist/utils/migration/resolveMigrationScript.js.map +0 -1
  110. /package/dist/actions/auth/login/{index.d.ts → login.d.ts} +0 -0
@@ -1,63 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { renameField } from '../renameField';
3
- describe('#renameField', ()=>{
4
- test('creates template with no doc types', ()=>{
5
- const renameFieldTemplate = renameField({
6
- documentTypes: [],
7
- migrationName: 'My Migration'
8
- });
9
- expect(renameFieldTemplate).toMatchInlineSnapshot(`
10
- "import {defineMigration, at, setIfMissing, unset} from '@sanity/migrate'
11
-
12
- const from = 'oldFieldName'
13
- const to = 'newFieldName'
14
-
15
- export default defineMigration({
16
- title: "My Migration",
17
-
18
- migrate: {
19
- document(doc, context) {
20
- return [
21
- at(to, setIfMissing(doc[from])),
22
- at(from, unset())
23
- ]
24
- }
25
- }
26
- })
27
- "
28
- `);
29
- });
30
- test('creates template with doc types', ()=>{
31
- const renameFieldTemplate = renameField({
32
- documentTypes: [
33
- 'document-1',
34
- 'document-2',
35
- 'document-3'
36
- ],
37
- migrationName: 'My Migration'
38
- });
39
- expect(renameFieldTemplate).toMatchInlineSnapshot(`
40
- "import {defineMigration, at, setIfMissing, unset} from '@sanity/migrate'
41
-
42
- const from = 'oldFieldName'
43
- const to = 'newFieldName'
44
-
45
- export default defineMigration({
46
- title: "My Migration",
47
- documentTypes: ["document-1", "document-2", "document-3"],
48
-
49
- migrate: {
50
- document(doc, context) {
51
- return [
52
- at(to, setIfMissing(doc[from])),
53
- at(from, unset())
54
- ]
55
- }
56
- }
57
- })
58
- "
59
- `);
60
- });
61
- });
62
-
63
- //# sourceMappingURL=renameField.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/actions/migration/templates/__tests__/renameField.test.ts"],"sourcesContent":["import {describe, expect, test} from 'vitest'\n\nimport {renameField} from '../renameField'\n\ndescribe('#renameField', () => {\n test('creates template with no doc types', () => {\n const renameFieldTemplate = renameField({\n documentTypes: [],\n migrationName: 'My Migration',\n })\n\n expect(renameFieldTemplate).toMatchInlineSnapshot(`\n \"import {defineMigration, at, setIfMissing, unset} from '@sanity/migrate'\n\n const from = 'oldFieldName'\n const to = 'newFieldName'\n\n export default defineMigration({\n title: \"My Migration\",\n\n migrate: {\n document(doc, context) {\n return [\n at(to, setIfMissing(doc[from])),\n at(from, unset())\n ]\n }\n }\n })\n \"\n `)\n })\n\n test('creates template with doc types', () => {\n const renameFieldTemplate = renameField({\n documentTypes: ['document-1', 'document-2', 'document-3'],\n migrationName: 'My Migration',\n })\n\n expect(renameFieldTemplate).toMatchInlineSnapshot(`\n \"import {defineMigration, at, setIfMissing, unset} from '@sanity/migrate'\n\n const from = 'oldFieldName'\n const to = 'newFieldName'\n\n export default defineMigration({\n title: \"My Migration\",\n documentTypes: [\"document-1\", \"document-2\", \"document-3\"],\n\n migrate: {\n document(doc, context) {\n return [\n at(to, setIfMissing(doc[from])),\n at(from, unset())\n ]\n }\n }\n })\n \"\n `)\n })\n})\n"],"names":["describe","expect","test","renameField","renameFieldTemplate","documentTypes","migrationName","toMatchInlineSnapshot"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAO,SAAQ;AAE7C,SAAQC,WAAW,QAAO,iBAAgB;AAE1CH,SAAS,gBAAgB;IACvBE,KAAK,sCAAsC;QACzC,MAAME,sBAAsBD,YAAY;YACtCE,eAAe,EAAE;YACjBC,eAAe;QACjB;QAEAL,OAAOG,qBAAqBG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;IAmBnD,CAAC;IACH;IAEAL,KAAK,mCAAmC;QACtC,MAAME,sBAAsBD,YAAY;YACtCE,eAAe;gBAAC;gBAAc;gBAAc;aAAa;YACzDC,eAAe;QACjB;QAEAL,OAAOG,qBAAqBG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;IAoBnD,CAAC;IACH;AACF"}
@@ -1,61 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { renameType } from '../renameType';
3
- describe('#renameType', ()=>{
4
- test('creates template with no doc types', ()=>{
5
- const renameTypeTemplate = renameType({
6
- documentTypes: [],
7
- migrationName: 'My Migration'
8
- });
9
- expect(renameTypeTemplate).toMatchInlineSnapshot(`
10
- "import {defineMigration, at, set} from '@sanity/migrate'
11
-
12
- const oldType = 'old'
13
- const newType = 'new'
14
-
15
- export default defineMigration({
16
- title: "My Migration",
17
-
18
- migrate: {
19
- object(object, path, context) {
20
- if (object._type === oldType) {
21
- return at('_type', set(newType))
22
- }
23
- }
24
- }
25
- })
26
- "
27
- `);
28
- });
29
- test('creates template with doc types', ()=>{
30
- const renameTypeTemplate = renameType({
31
- documentTypes: [
32
- 'document-1',
33
- 'document-2',
34
- 'document-3'
35
- ],
36
- migrationName: 'My Migration'
37
- });
38
- expect(renameTypeTemplate).toMatchInlineSnapshot(`
39
- "import {defineMigration, at, set} from '@sanity/migrate'
40
-
41
- const oldType = 'old'
42
- const newType = 'new'
43
-
44
- export default defineMigration({
45
- title: "My Migration",
46
- documentTypes: ["document-1", "document-2", "document-3"],
47
-
48
- migrate: {
49
- object(object, path, context) {
50
- if (object._type === oldType) {
51
- return at('_type', set(newType))
52
- }
53
- }
54
- }
55
- })
56
- "
57
- `);
58
- });
59
- });
60
-
61
- //# sourceMappingURL=renameType.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/actions/migration/templates/__tests__/renameType.test.ts"],"sourcesContent":["import {describe, expect, test} from 'vitest'\n\nimport {renameType} from '../renameType'\n\ndescribe('#renameType', () => {\n test('creates template with no doc types', () => {\n const renameTypeTemplate = renameType({\n documentTypes: [],\n migrationName: 'My Migration',\n })\n\n expect(renameTypeTemplate).toMatchInlineSnapshot(`\n \"import {defineMigration, at, set} from '@sanity/migrate'\n\n const oldType = 'old'\n const newType = 'new'\n\n export default defineMigration({\n title: \"My Migration\",\n\n migrate: {\n object(object, path, context) {\n if (object._type === oldType) {\n return at('_type', set(newType))\n }\n }\n }\n })\n \"\n `)\n })\n\n test('creates template with doc types', () => {\n const renameTypeTemplate = renameType({\n documentTypes: ['document-1', 'document-2', 'document-3'],\n migrationName: 'My Migration',\n })\n\n expect(renameTypeTemplate).toMatchInlineSnapshot(`\n \"import {defineMigration, at, set} from '@sanity/migrate'\n\n const oldType = 'old'\n const newType = 'new'\n\n export default defineMigration({\n title: \"My Migration\",\n documentTypes: [\"document-1\", \"document-2\", \"document-3\"],\n\n migrate: {\n object(object, path, context) {\n if (object._type === oldType) {\n return at('_type', set(newType))\n }\n }\n }\n })\n \"\n `)\n })\n})\n"],"names":["describe","expect","test","renameType","renameTypeTemplate","documentTypes","migrationName","toMatchInlineSnapshot"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAO,SAAQ;AAE7C,SAAQC,UAAU,QAAO,gBAAe;AAExCH,SAAS,eAAe;IACtBE,KAAK,sCAAsC;QACzC,MAAME,qBAAqBD,WAAW;YACpCE,eAAe,EAAE;YACjBC,eAAe;QACjB;QAEAL,OAAOG,oBAAoBG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;IAkBlD,CAAC;IACH;IAEAL,KAAK,mCAAmC;QACtC,MAAME,qBAAqBD,WAAW;YACpCE,eAAe;gBAAC;gBAAc;gBAAc;aAAa;YACzDC,eAAe;QACjB;QAEAL,OAAOG,oBAAoBG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;IAmBlD,CAAC;IACH;AACF"}
@@ -1,87 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { stringToPTE } from '../stringToPTE';
3
- describe('#stringToPTE', ()=>{
4
- test('creates template with no doc types', ()=>{
5
- const stringToPTETemplate = stringToPTE({
6
- documentTypes: [],
7
- migrationName: 'My Migration'
8
- });
9
- expect(stringToPTETemplate).toMatchInlineSnapshot(`
10
- "import {pathsAreEqual, stringToPath} from 'sanity'
11
- import {defineMigration, set} from '@sanity/migrate'
12
-
13
- const targetPath = stringToPath('some.path')
14
-
15
- export default defineMigration({
16
- title: "My Migration",
17
-
18
- migrate: {
19
- string(node, path, ctx) {
20
- if (pathsAreEqual(path, targetPath)) {
21
- return set([
22
- {
23
- style: 'normal',
24
- _type: 'block',
25
- children: [
26
- {
27
- _type: 'span',
28
- marks: [],
29
- text: node,
30
- },
31
- ],
32
- markDefs: [],
33
- },
34
- ])
35
- }
36
- },
37
- },
38
- })
39
- "
40
- `);
41
- });
42
- test('creates template with doc types', ()=>{
43
- const stringToPTETemplate = stringToPTE({
44
- documentTypes: [
45
- 'document-1',
46
- 'document-2',
47
- 'document-3'
48
- ],
49
- migrationName: 'My Migration'
50
- });
51
- expect(stringToPTETemplate).toMatchInlineSnapshot(`
52
- "import {pathsAreEqual, stringToPath} from 'sanity'
53
- import {defineMigration, set} from '@sanity/migrate'
54
-
55
- const targetPath = stringToPath('some.path')
56
-
57
- export default defineMigration({
58
- title: "My Migration",
59
- documentTypes: ["document-1", "document-2", "document-3"],
60
-
61
- migrate: {
62
- string(node, path, ctx) {
63
- if (pathsAreEqual(path, targetPath)) {
64
- return set([
65
- {
66
- style: 'normal',
67
- _type: 'block',
68
- children: [
69
- {
70
- _type: 'span',
71
- marks: [],
72
- text: node,
73
- },
74
- ],
75
- markDefs: [],
76
- },
77
- ])
78
- }
79
- },
80
- },
81
- })
82
- "
83
- `);
84
- });
85
- });
86
-
87
- //# sourceMappingURL=stringToPTE.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/actions/migration/templates/__tests__/stringToPTE.test.ts"],"sourcesContent":["import {describe, expect, test} from 'vitest'\n\nimport {stringToPTE} from '../stringToPTE'\n\ndescribe('#stringToPTE', () => {\n test('creates template with no doc types', () => {\n const stringToPTETemplate = stringToPTE({\n documentTypes: [],\n migrationName: 'My Migration',\n })\n\n expect(stringToPTETemplate).toMatchInlineSnapshot(`\n \"import {pathsAreEqual, stringToPath} from 'sanity'\n import {defineMigration, set} from '@sanity/migrate'\n\n const targetPath = stringToPath('some.path')\n\n export default defineMigration({\n title: \"My Migration\",\n\n migrate: {\n string(node, path, ctx) {\n if (pathsAreEqual(path, targetPath)) {\n return set([\n {\n style: 'normal',\n _type: 'block',\n children: [\n {\n _type: 'span',\n marks: [],\n text: node,\n },\n ],\n markDefs: [],\n },\n ])\n }\n },\n },\n })\n \"\n `)\n })\n\n test('creates template with doc types', () => {\n const stringToPTETemplate = stringToPTE({\n documentTypes: ['document-1', 'document-2', 'document-3'],\n migrationName: 'My Migration',\n })\n\n expect(stringToPTETemplate).toMatchInlineSnapshot(`\n \"import {pathsAreEqual, stringToPath} from 'sanity'\n import {defineMigration, set} from '@sanity/migrate'\n\n const targetPath = stringToPath('some.path')\n\n export default defineMigration({\n title: \"My Migration\",\n documentTypes: [\"document-1\", \"document-2\", \"document-3\"],\n\n migrate: {\n string(node, path, ctx) {\n if (pathsAreEqual(path, targetPath)) {\n return set([\n {\n style: 'normal',\n _type: 'block',\n children: [\n {\n _type: 'span',\n marks: [],\n text: node,\n },\n ],\n markDefs: [],\n },\n ])\n }\n },\n },\n })\n \"\n `)\n })\n})\n"],"names":["describe","expect","test","stringToPTE","stringToPTETemplate","documentTypes","migrationName","toMatchInlineSnapshot"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAO,SAAQ;AAE7C,SAAQC,WAAW,QAAO,iBAAgB;AAE1CH,SAAS,gBAAgB;IACvBE,KAAK,sCAAsC;QACzC,MAAME,sBAAsBD,YAAY;YACtCE,eAAe,EAAE;YACjBC,eAAe;QACjB;QAEAL,OAAOG,qBAAqBG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+BnD,CAAC;IACH;IAEAL,KAAK,mCAAmC;QACtC,MAAME,sBAAsBD,YAAY;YACtCE,eAAe;gBAAC;gBAAc;gBAAc;aAAa;YACzDC,eAAe;QACjB;QAEAL,OAAOG,qBAAqBG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgCnD,CAAC;IACH;AACF"}
@@ -1,5 +0,0 @@
1
- export { minimalAdvanced } from './minimalAdvanced.js';
2
- export { minimalSimple } from './minimalSimple.js';
3
- export { renameField } from './renameField.js';
4
- export { renameType } from './renameType.js';
5
- export { stringToPTE } from './stringToPTE.js';
@@ -1,7 +0,0 @@
1
- export { minimalAdvanced } from './minimalAdvanced.js';
2
- export { minimalSimple } from './minimalSimple.js';
3
- export { renameField } from './renameField.js';
4
- export { renameType } from './renameType.js';
5
- export { stringToPTE } from './stringToPTE.js';
6
-
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/migration/templates/index.ts"],"sourcesContent":["export {minimalAdvanced} from './minimalAdvanced.js'\nexport {minimalSimple} from './minimalSimple.js'\nexport {renameField} from './renameField.js'\nexport {renameType} from './renameType.js'\nexport {stringToPTE} from './stringToPTE.js'\n"],"names":["minimalAdvanced","minimalSimple","renameField","renameType","stringToPTE"],"mappings":"AAAA,SAAQA,eAAe,QAAO,uBAAsB;AACpD,SAAQC,aAAa,QAAO,qBAAoB;AAChD,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,UAAU,QAAO,kBAAiB;AAC1C,SAAQC,WAAW,QAAO,mBAAkB"}
@@ -1,4 +0,0 @@
1
- export declare const minimalAdvanced: ({ documentTypes, migrationName, }: {
2
- documentTypes: string[];
3
- migrationName: string;
4
- }) => string;
@@ -1,21 +0,0 @@
1
- export const minimalAdvanced = ({ documentTypes, migrationName })=>`import {defineMigration, patch, at, setIfMissing} from '@sanity/migrate'
2
-
3
- /**
4
- * this migration will set \`Default title\` on all documents that are missing a title
5
- * and make \`true\` the default value for the \`enabled\` field
6
- */
7
- export default defineMigration({
8
- title: ${JSON.stringify(migrationName)},
9
- ${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
10
- async *migrate(documents, context) {
11
- for await (const document of documents()) {
12
- yield patch(document._id, [
13
- at('title', setIfMissing('Default title')),
14
- at('enabled', setIfMissing(true)),
15
- ])
16
- }
17
- }
18
- })
19
- `;
20
-
21
- //# sourceMappingURL=minimalAdvanced.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/migration/templates/minimalAdvanced.ts"],"sourcesContent":["export const minimalAdvanced = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {defineMigration, patch, at, setIfMissing} from '@sanity/migrate'\n\n/**\n * this migration will set \\`Default title\\` on all documents that are missing a title\n * and make \\`true\\` the default value for the \\`enabled\\` field\n */\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n async *migrate(documents, context) {\n for await (const document of documents()) {\n yield patch(document._id, [\n at('title', setIfMissing('Default title')),\n at('enabled', setIfMissing(true)),\n ])\n }\n }\n})\n`\n"],"names":["minimalAdvanced","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,CAAC,EAC9BC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;;;;;SAOE,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;;AAUD,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- export declare const minimalSimple: ({ documentTypes, migrationName, }: {
2
- documentTypes: string[];
3
- migrationName: string;
4
- }) => string;
@@ -1,61 +0,0 @@
1
- export const minimalSimple = ({ documentTypes, migrationName })=>`import {at, defineMigration, setIfMissing, unset} from '@sanity/migrate'
2
-
3
- export default defineMigration({
4
- title: ${JSON.stringify(migrationName)},
5
- ${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
6
- migrate: {
7
- document(doc, context) {
8
- // this will be called for every document of the matching type
9
- // any patch returned will be applied to the document
10
- // you can also return mutations that touches other documents
11
-
12
- return at('title', setIfMissing('Default title'))
13
- },
14
- node(node, path, context) {
15
- // this will be called for every node in every document of the matching type
16
- // any patch returned will be applied to the document
17
- // you can also return mutations that touches other documents
18
-
19
- if (typeof node === 'string' && node === 'deleteme') {
20
- return unset()
21
- }
22
- },
23
- object(node, path, context) {
24
- // this will be called for every object node in every document of the matching type
25
- // any patch returned will be applied to the document
26
- // you can also return mutations that touches other documents
27
- if (node._type === 'author') {
28
- // make sure all authors objects have a books array
29
- return at('books', setIfMissing([]))
30
- }
31
- },
32
- array(node, path, context) {
33
- // this will be called for every array node in every document of the matching type
34
- // any patch returned will be applied to the document
35
- // you can also return mutations that touches other documents
36
- },
37
- string(node, path, context) {
38
- // this will be called for every string node in every document of the matching type
39
- // any patch returned will be applied to the document
40
- // you can also return mutations that touches other documents
41
- },
42
- number(node, path, context) {
43
- // this will be called for every number node in every document of the matching type
44
- // any patch returned will be applied to the document
45
- // you can also return mutations that touches other documents
46
- },
47
- boolean(node, path, context) {
48
- // this will be called for every boolean node in every document of the matching type
49
- // any patch returned will be applied to the document
50
- // you can also return mutations that touches other documents
51
- },
52
- null(node, path, context) {
53
- // this will be called for every null node in every document of the matching type
54
- // any patch returned will be applied to the document
55
- // you can also return mutations that touches other documents
56
- },
57
- },
58
- })
59
- `;
60
-
61
- //# sourceMappingURL=minimalSimple.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/migration/templates/minimalSimple.ts"],"sourcesContent":["export const minimalSimple = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {at, defineMigration, setIfMissing, unset} from '@sanity/migrate'\n\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n migrate: {\n document(doc, context) {\n // this will be called for every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n\n return at('title', setIfMissing('Default title'))\n },\n node(node, path, context) {\n // this will be called for every node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n\n if (typeof node === 'string' && node === 'deleteme') {\n return unset()\n }\n },\n object(node, path, context) {\n // this will be called for every object node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n if (node._type === 'author') {\n // make sure all authors objects have a books array\n return at('books', setIfMissing([]))\n }\n },\n array(node, path, context) {\n // this will be called for every array node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n string(node, path, context) {\n // this will be called for every string node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n number(node, path, context) {\n // this will be called for every number node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n boolean(node, path, context) {\n // this will be called for every boolean node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n null(node, path, context) {\n // this will be called for every null node in every document of the matching type\n // any patch returned will be applied to the document\n // you can also return mutations that touches other documents\n },\n },\n})\n`\n"],"names":["minimalSimple","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,CAAC,EAC5BC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;SAGE,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDD,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- export declare const renameField: ({ documentTypes, migrationName, }: {
2
- documentTypes: string[];
3
- migrationName: string;
4
- }) => string;
@@ -1,20 +0,0 @@
1
- export const renameField = ({ documentTypes, migrationName })=>`import {defineMigration, at, setIfMissing, unset} from '@sanity/migrate'
2
-
3
- const from = 'oldFieldName'
4
- const to = 'newFieldName'
5
-
6
- export default defineMigration({
7
- title: ${JSON.stringify(migrationName)},
8
- ${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
9
- migrate: {
10
- document(doc, context) {
11
- return [
12
- at(to, setIfMissing(doc[from])),
13
- at(from, unset())
14
- ]
15
- }
16
- }
17
- })
18
- `;
19
-
20
- //# sourceMappingURL=renameField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/migration/templates/renameField.ts"],"sourcesContent":["export const renameField = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {defineMigration, at, setIfMissing, unset} from '@sanity/migrate'\n\nconst from = 'oldFieldName'\nconst to = 'newFieldName'\n\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n migrate: {\n document(doc, context) {\n return [\n at(to, setIfMissing(doc[from])),\n at(from, unset())\n ]\n }\n }\n})\n`\n"],"names":["renameField","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,cAAc,CAAC,EAC1BC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;;;;SAME,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;;AAUD,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- export declare const renameType: ({ documentTypes, migrationName, }: {
2
- documentTypes: string[];
3
- migrationName: string;
4
- }) => string;
@@ -1,19 +0,0 @@
1
- export const renameType = ({ documentTypes, migrationName })=>`import {defineMigration, at, set} from '@sanity/migrate'
2
-
3
- const oldType = 'old'
4
- const newType = 'new'
5
-
6
- export default defineMigration({
7
- title: ${JSON.stringify(migrationName)},
8
- ${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
9
- migrate: {
10
- object(object, path, context) {
11
- if (object._type === oldType) {
12
- return at('_type', set(newType))
13
- }
14
- }
15
- }
16
- })
17
- `;
18
-
19
- //# sourceMappingURL=renameType.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/migration/templates/renameType.ts"],"sourcesContent":["export const renameType = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {defineMigration, at, set} from '@sanity/migrate'\n\nconst oldType = 'old'\nconst newType = 'new'\n\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n migrate: {\n object(object, path, context) {\n if (object._type === oldType) {\n return at('_type', set(newType))\n }\n }\n }\n})\n`\n"],"names":["renameType","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,aAAa,CAAC,EACzBC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;;;;SAME,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;AASD,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- export declare const stringToPTE: ({ documentTypes, migrationName, }: {
2
- documentTypes: string[];
3
- migrationName: string;
4
- }) => string;
@@ -1,32 +0,0 @@
1
- export const stringToPTE = ({ documentTypes, migrationName })=>`import {pathsAreEqual, stringToPath} from 'sanity'
2
- import {defineMigration, set} from '@sanity/migrate'
3
-
4
- const targetPath = stringToPath('some.path')
5
-
6
- export default defineMigration({
7
- title: ${JSON.stringify(migrationName)},
8
- ${documentTypes.length > 0 ? ` documentTypes: [${documentTypes.map((t)=>JSON.stringify(t)).join(', ')}],\n` : ''}
9
- migrate: {
10
- string(node, path, ctx) {
11
- if (pathsAreEqual(path, targetPath)) {
12
- return set([
13
- {
14
- style: 'normal',
15
- _type: 'block',
16
- children: [
17
- {
18
- _type: 'span',
19
- marks: [],
20
- text: node,
21
- },
22
- ],
23
- markDefs: [],
24
- },
25
- ])
26
- }
27
- },
28
- },
29
- })
30
- `;
31
-
32
- //# sourceMappingURL=stringToPTE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/migration/templates/stringToPTE.ts"],"sourcesContent":["export const stringToPTE = ({\n documentTypes,\n migrationName,\n}: {\n documentTypes: string[]\n migrationName: string\n}) => `import {pathsAreEqual, stringToPath} from 'sanity'\nimport {defineMigration, set} from '@sanity/migrate'\n\nconst targetPath = stringToPath('some.path')\n\nexport default defineMigration({\n title: ${JSON.stringify(migrationName)},\n${\n documentTypes.length > 0\n ? ` documentTypes: [${documentTypes.map((t) => JSON.stringify(t)).join(', ')}],\\n`\n : ''\n}\n migrate: {\n string(node, path, ctx) {\n if (pathsAreEqual(path, targetPath)) {\n return set([\n {\n style: 'normal',\n _type: 'block',\n children: [\n {\n _type: 'span',\n marks: [],\n text: node,\n },\n ],\n markDefs: [],\n },\n ])\n }\n },\n },\n})\n`\n"],"names":["stringToPTE","documentTypes","migrationName","JSON","stringify","length","map","t","join"],"mappings":"AAAA,OAAO,MAAMA,cAAc,CAAC,EAC1BC,aAAa,EACbC,aAAa,EAId,GAAK,CAAC;;;;;;SAME,EAAEC,KAAKC,SAAS,CAACF,eAAe;AACzC,EACED,cAAcI,MAAM,GAAG,IACnB,CAAC,kBAAkB,EAAEJ,cAAcK,GAAG,CAAC,CAACC,IAAMJ,KAAKC,SAAS,CAACG,IAAIC,IAAI,CAAC,MAAM,IAAI,CAAC,GACjF,GACL;;;;;;;;;;;;;;;;;;;;;;AAsBD,CAAC,CAAA"}