@dittowords/cli 3.9.0 → 3.10.0

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 (63) hide show
  1. package/README.md +11 -2
  2. package/bin/lib/add-project.js +36 -0
  3. package/bin/lib/add-project.js.map +1 -0
  4. package/bin/lib/api.js +20 -0
  5. package/bin/lib/api.js.map +1 -0
  6. package/bin/lib/config.js +202 -0
  7. package/bin/lib/config.js.map +1 -0
  8. package/bin/lib/consts.js +21 -0
  9. package/bin/lib/consts.js.map +1 -0
  10. package/bin/lib/ditto.js +121 -0
  11. package/bin/lib/ditto.js.map +1 -0
  12. package/bin/lib/generate-suggestions.js +71 -0
  13. package/bin/lib/generate-suggestions.js.map +1 -0
  14. package/bin/lib/http/fetchComponents.js +13 -0
  15. package/bin/lib/http/fetchComponents.js.map +1 -0
  16. package/bin/lib/http/fetchVariants.js +26 -0
  17. package/bin/lib/http/fetchVariants.js.map +1 -0
  18. package/bin/lib/init/init.js +50 -0
  19. package/bin/lib/init/init.js.map +1 -0
  20. package/bin/lib/init/project.js +108 -0
  21. package/bin/lib/init/project.js.map +1 -0
  22. package/bin/lib/init/token.js +91 -0
  23. package/bin/lib/init/token.js.map +1 -0
  24. package/bin/lib/output.js +34 -0
  25. package/bin/lib/output.js.map +1 -0
  26. package/bin/lib/pull.js +264 -0
  27. package/bin/lib/pull.js.map +1 -0
  28. package/bin/lib/remove-project.js +35 -0
  29. package/bin/lib/remove-project.js.map +1 -0
  30. package/bin/lib/replace.js +107 -0
  31. package/bin/lib/replace.js.map +1 -0
  32. package/bin/lib/types.js +3 -0
  33. package/bin/lib/types.js.map +1 -0
  34. package/bin/lib/utils/cleanFileName.js +11 -0
  35. package/bin/lib/utils/cleanFileName.js.map +1 -0
  36. package/bin/lib/utils/generateJsDriver.js +56 -0
  37. package/bin/lib/utils/generateJsDriver.js.map +1 -0
  38. package/bin/lib/utils/getSelectedProjects.js +61 -0
  39. package/bin/lib/utils/getSelectedProjects.js.map +1 -0
  40. package/bin/lib/utils/processMetaOption.js +15 -0
  41. package/bin/lib/utils/processMetaOption.js.map +1 -0
  42. package/bin/lib/utils/projectsToText.js +25 -0
  43. package/bin/lib/utils/projectsToText.js.map +1 -0
  44. package/bin/lib/utils/promptForProject.js +43 -0
  45. package/bin/lib/utils/promptForProject.js.map +1 -0
  46. package/bin/lib/utils/quit.js +10 -0
  47. package/bin/lib/utils/quit.js.map +1 -0
  48. package/bin/lib/utils/sourcesToText.js +25 -0
  49. package/bin/lib/utils/sourcesToText.js.map +1 -0
  50. package/bin/package.json +76 -0
  51. package/bin/pull.js +18 -8
  52. package/bin/pull.js.map +1 -1
  53. package/lib/pull.ts +29 -9
  54. package/lib/types.ts +1 -1
  55. package/package.json +1 -1
  56. package/.idea/cli.iml +0 -13
  57. package/.idea/codeStyles/Project.xml +0 -65
  58. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  59. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  60. package/.idea/modules.xml +0 -8
  61. package/.idea/prettier.xml +0 -6
  62. package/.idea/vcs.xml +0 -6
  63. package/.idea/workspace.xml +0 -220
package/lib/pull.ts CHANGED
@@ -43,13 +43,20 @@ const getFormatDataIsValid = {
43
43
  "ios-stringsdict": (data: string) => data.includes("<key>"),
44
44
  };
45
45
 
46
- const getFormat = (formatFromSource: string | undefined): SupportedFormat => {
47
- const f = formatFromSource as SupportedFormat | undefined;
48
- if (f && SUPPORTED_FORMATS.includes(f)) {
49
- return f;
46
+ const getFormat = (
47
+ formatFromSource: string | string[] | undefined
48
+ ): SupportedFormat[] => {
49
+ const formats = (
50
+ Array.isArray(formatFromSource) ? formatFromSource : [formatFromSource]
51
+ ).filter((format) =>
52
+ SUPPORTED_FORMATS.includes(format as SupportedFormat)
53
+ ) as SupportedFormat[];
54
+
55
+ if (formats.length) {
56
+ return formats;
50
57
  }
51
58
 
52
- return "flat";
59
+ return ["flat"];
53
60
  };
54
61
 
55
62
  const getFormatExtension = (format: SupportedFormat) => {
@@ -226,7 +233,7 @@ async function downloadAndSave(
226
233
  componentFolders,
227
234
  } = source;
228
235
 
229
- const format = getFormat(formatFromSource);
236
+ const formats = getFormat(formatFromSource);
230
237
 
231
238
  let msg = "";
232
239
  const spinner = ora(msg);
@@ -243,7 +250,7 @@ async function downloadAndSave(
243
250
 
244
251
  const meta = options ? options.meta : {};
245
252
 
246
- if (shouldFetchComponentLibrary) {
253
+ async function fetchComponentLibrary(format: SupportedFormat) {
247
254
  // Always include a variant with an apiID of undefined to ensure that we
248
255
  // fetch the base text for the component library.
249
256
  const componentVariants = [{ apiID: undefined }, ...(variants || [])];
@@ -290,7 +297,13 @@ async function downloadAndSave(
290
297
  msg += messages.join("");
291
298
  }
292
299
 
293
- if (validProjects.length) {
300
+ if (shouldFetchComponentLibrary) {
301
+ for (const format of formats) {
302
+ await fetchComponentLibrary(format);
303
+ }
304
+ }
305
+
306
+ async function fetchProjects(format: SupportedFormat) {
294
307
  msg += variants
295
308
  ? await downloadAndSaveVariants(
296
309
  variants,
@@ -312,6 +325,12 @@ async function downloadAndSave(
312
325
  );
313
326
  }
314
327
 
328
+ if (validProjects.length) {
329
+ for (const format of formats) {
330
+ await fetchProjects(format);
331
+ }
332
+ }
333
+
315
334
  const sources = [...validProjects];
316
335
  if (shouldFetchComponentLibrary) {
317
336
  sources.push({
@@ -321,7 +340,8 @@ async function downloadAndSave(
321
340
  });
322
341
  }
323
342
 
324
- if (JSON_FORMATS.includes(format)) msg += generateJsDriver(sources);
343
+ if (formats.some((f) => JSON_FORMATS.includes(f)))
344
+ msg += generateJsDriver(sources);
325
345
 
326
346
  msg += `\n${output.success("Done")}!`;
327
347
 
package/lib/types.ts CHANGED
@@ -45,7 +45,7 @@ export interface SourceInformation {
45
45
  validProjects: Project[];
46
46
  shouldFetchComponentLibrary: boolean;
47
47
  variants: boolean;
48
- format: string | undefined;
48
+ format: string | string[] | undefined;
49
49
  status: string | undefined;
50
50
  richText: boolean | undefined;
51
51
  componentFolders: ComponentFolder[] | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dittowords/cli",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "description": "Command Line Interface for Ditto (dittowords.com).",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {
package/.idea/cli.iml DELETED
@@ -1,13 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/temp" />
6
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
- <excludeFolder url="file://$MODULE_DIR$/bin" />
9
- </content>
10
- <orderEntry type="inheritedJdk" />
11
- <orderEntry type="sourceFolder" forTests="false" />
12
- </component>
13
- </module>
@@ -1,65 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <HTMLCodeStyleSettings>
4
- <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
5
- <option name="HTML_ENFORCE_QUOTES" value="true" />
6
- </HTMLCodeStyleSettings>
7
- <JSCodeStyleSettings version="0">
8
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
9
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
10
- <option name="FORCE_QUOTE_STYlE" value="true" />
11
- <option name="ENFORCE_TRAILING_COMMA" value="Remove" />
12
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
13
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
14
- </JSCodeStyleSettings>
15
- <TypeScriptCodeStyleSettings version="0">
16
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
17
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
18
- <option name="FORCE_QUOTE_STYlE" value="true" />
19
- <option name="ENFORCE_TRAILING_COMMA" value="Remove" />
20
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
21
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
22
- </TypeScriptCodeStyleSettings>
23
- <VueCodeStyleSettings>
24
- <option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
25
- <option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
26
- </VueCodeStyleSettings>
27
- <codeStyleSettings language="CSS">
28
- <indentOptions>
29
- <option name="INDENT_SIZE" value="2" />
30
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
31
- <option name="TAB_SIZE" value="2" />
32
- </indentOptions>
33
- </codeStyleSettings>
34
- <codeStyleSettings language="HTML">
35
- <option name="SOFT_MARGINS" value="80" />
36
- <indentOptions>
37
- <option name="INDENT_SIZE" value="2" />
38
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
39
- <option name="TAB_SIZE" value="2" />
40
- </indentOptions>
41
- </codeStyleSettings>
42
- <codeStyleSettings language="JavaScript">
43
- <option name="SOFT_MARGINS" value="80" />
44
- <indentOptions>
45
- <option name="INDENT_SIZE" value="2" />
46
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
47
- <option name="TAB_SIZE" value="2" />
48
- </indentOptions>
49
- </codeStyleSettings>
50
- <codeStyleSettings language="TypeScript">
51
- <option name="SOFT_MARGINS" value="80" />
52
- <indentOptions>
53
- <option name="INDENT_SIZE" value="2" />
54
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
55
- <option name="TAB_SIZE" value="2" />
56
- </indentOptions>
57
- </codeStyleSettings>
58
- <codeStyleSettings language="Vue">
59
- <option name="SOFT_MARGINS" value="80" />
60
- <indentOptions>
61
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
62
- </indentOptions>
63
- </codeStyleSettings>
64
- </code_scheme>
65
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- </profile>
6
- </component>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/cli.iml" filepath="$PROJECT_DIR$/.idea/cli.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="PrettierConfiguration">
4
- <option name="myRunOnSave" value="true" />
5
- </component>
6
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
@@ -1,220 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ChangeListManager">
4
- <list default="true" id="d2834f12-3435-41b5-8efa-c62f3f4baa0d" name="Changes" comment="Add remaining column mappings">
5
- <change beforePath="$PROJECT_DIR$/lib/ditto.ts" beforeDir="false" afterPath="$PROJECT_DIR$/lib/ditto.ts" afterDir="false" />
6
- </list>
7
- <option name="SHOW_DIALOG" value="false" />
8
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
9
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
10
- <option name="LAST_RESOLUTION" value="IGNORE" />
11
- </component>
12
- <component name="Git.Settings">
13
- <option name="RECENT_BRANCH_BY_REPOSITORY">
14
- <map>
15
- <entry key="$PROJECT_DIR$" value="master" />
16
- </map>
17
- </option>
18
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
19
- </component>
20
- <component name="GitSEFilterConfiguration">
21
- <file-type-list>
22
- <filtered-out-file-type name="LOCAL_BRANCH" />
23
- <filtered-out-file-type name="REMOTE_BRANCH" />
24
- <filtered-out-file-type name="TAG" />
25
- <filtered-out-file-type name="COMMIT_BY_MESSAGE" />
26
- </file-type-list>
27
- </component>
28
- <component name="ProjectId" id="2QnCWGsMrfsa99lySJEn0m45dgP" />
29
- <component name="ProjectViewState">
30
- <option name="hideEmptyMiddlePackages" value="true" />
31
- <option name="showLibraryContents" value="true" />
32
- <option name="showMembers" value="true" />
33
- </component>
34
- <component name="PropertiesComponent">
35
- <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
36
- <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
37
- <property name="WebServerToolWindowFactoryState" value="false" />
38
- <property name="last_opened_file_path" value="$PROJECT_DIR$/lib/http" />
39
- <property name="node.js.detected.package.eslint" value="true" />
40
- <property name="node.js.detected.package.standard" value="true" />
41
- <property name="node.js.selected.package.eslint" value="(autodetect)" />
42
- <property name="node.js.selected.package.standard" value="" />
43
- <property name="nodejs.jest.jest_package" value="$PROJECT_DIR$/node_modules/jest" />
44
- <property name="nodejs_package_manager_path" value="yarn" />
45
- <property name="prettierjs.PrettierConfiguration.Package" value="$PROJECT_DIR$/node_modules/prettier" />
46
- <property name="settings.editor.selected.configurable" value="settings.javascript.prettier" />
47
- <property name="ts.external.directory.path" value="$PROJECT_DIR$/node_modules/typescript/lib" />
48
- <property name="vue.rearranger.settings.migration" value="true" />
49
- </component>
50
- <component name="RecentsManager">
51
- <key name="CopyFile.RECENT_KEYS">
52
- <recent name="$PROJECT_DIR$/lib/http" />
53
- </key>
54
- </component>
55
- <component name="RunManager">
56
- <configuration name="generate-suggestions.test.ts" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
57
- <node-interpreter value="project" />
58
- <node-options value="" />
59
- <jest-package value="$PROJECT_DIR$/node_modules/jest" />
60
- <working-dir value="$PROJECT_DIR$" />
61
- <envs />
62
- <scope-kind value="TEST_FILE" />
63
- <test-file value="$PROJECT_DIR$/lib/generate-suggestions.test.ts" />
64
- <method v="2" />
65
- </configuration>
66
- <recent_temporary>
67
- <list>
68
- <item itemvalue="Jest.generate-suggestions.test.ts" />
69
- </list>
70
- </recent_temporary>
71
- </component>
72
- <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
73
- <component name="TaskManager">
74
- <task active="true" id="Default" summary="Default task">
75
- <changelist id="d2834f12-3435-41b5-8efa-c62f3f4baa0d" name="Changes" comment="" />
76
- <created>1685979990050</created>
77
- <option name="number" value="Default" />
78
- <option name="presentableId" value="Default" />
79
- <updated>1685979990050</updated>
80
- <workItem from="1685979994523" duration="162000" />
81
- <workItem from="1685980169522" duration="92000" />
82
- <workItem from="1685980274824" duration="41000" />
83
- <workItem from="1685980327587" duration="27000" />
84
- <workItem from="1685980367078" duration="303000" />
85
- <workItem from="1685980682884" duration="824000" />
86
- <workItem from="1685986712012" duration="5115000" />
87
- <workItem from="1686000886228" duration="2633000" />
88
- <workItem from="1686069506429" duration="76000" />
89
- <workItem from="1686087849012" duration="140000" />
90
- <workItem from="1686168915499" duration="2643000" />
91
- <workItem from="1686172029566" duration="5629000" />
92
- <workItem from="1686604031092" duration="6110000" />
93
- <workItem from="1686665537695" duration="7000" />
94
- <workItem from="1686666962638" duration="1318000" />
95
- <workItem from="1686672751040" duration="103000" />
96
- <workItem from="1686758001057" duration="1199000" />
97
- <workItem from="1686764622070" duration="41000" />
98
- </task>
99
- <task id="LOCAL-00001" summary="Remove eslint">
100
- <created>1685986802039</created>
101
- <option name="number" value="00001" />
102
- <option name="presentableId" value="LOCAL-00001" />
103
- <option name="project" value="LOCAL" />
104
- <updated>1685986802039</updated>
105
- </task>
106
- <task id="LOCAL-00002" summary="Add -cf flag to generate-suggestions">
107
- <created>1685993746601</created>
108
- <option name="number" value="00002" />
109
- <option name="presentableId" value="LOCAL-00002" />
110
- <option name="project" value="LOCAL" />
111
- <updated>1685993746601</updated>
112
- </task>
113
- <task id="LOCAL-00003" summary="Remove redundant variable">
114
- <created>1685993770336</created>
115
- <option name="number" value="00003" />
116
- <option name="presentableId" value="LOCAL-00003" />
117
- <option name="project" value="LOCAL" />
118
- <updated>1685993770336</updated>
119
- </task>
120
- <task id="LOCAL-00004" summary="Add command to show component-folders">
121
- <created>1686001523646</created>
122
- <option name="number" value="00004" />
123
- <option name="presentableId" value="LOCAL-00004" />
124
- <option name="project" value="LOCAL" />
125
- <updated>1686001523646</updated>
126
- </task>
127
- <task id="LOCAL-00005" summary="Command description">
128
- <created>1686002294377</created>
129
- <option name="number" value="00005" />
130
- <option name="presentableId" value="LOCAL-00005" />
131
- <option name="project" value="LOCAL" />
132
- <updated>1686002294377</updated>
133
- </task>
134
- <task id="LOCAL-00006" summary="Stringify print">
135
- <created>1686069574434</created>
136
- <option name="number" value="00006" />
137
- <option name="presentableId" value="LOCAL-00006" />
138
- <option name="project" value="LOCAL" />
139
- <updated>1686069574434</updated>
140
- </task>
141
- <task id="LOCAL-00007" summary="Add import-component function">
142
- <created>1686238984111</created>
143
- <option name="number" value="00007" />
144
- <option name="presentableId" value="LOCAL-00007" />
145
- <option name="project" value="LOCAL" />
146
- <updated>1686238984111</updated>
147
- </task>
148
- <task id="LOCAL-00008" summary="simplify generate-suggestions flag passing">
149
- <created>1686244114837</created>
150
- <option name="number" value="00008" />
151
- <option name="presentableId" value="LOCAL-00008" />
152
- <option name="project" value="LOCAL" />
153
- <updated>1686244114837</updated>
154
- </task>
155
- <task id="LOCAL-00009" summary="Add import-components command">
156
- <created>1686611039840</created>
157
- <option name="number" value="00009" />
158
- <option name="presentableId" value="LOCAL-00009" />
159
- <option name="project" value="LOCAL" />
160
- <updated>1686611039840</updated>
161
- </task>
162
- <task id="LOCAL-00010" summary="Add flag check for csv files">
163
- <created>1686667259055</created>
164
- <option name="number" value="00010" />
165
- <option name="presentableId" value="LOCAL-00010" />
166
- <option name="project" value="LOCAL" />
167
- <updated>1686667259055</updated>
168
- </task>
169
- <task id="LOCAL-00011" summary="Add (.csv format only)">
170
- <created>1686758043695</created>
171
- <option name="number" value="00011" />
172
- <option name="presentableId" value="LOCAL-00011" />
173
- <option name="project" value="LOCAL" />
174
- <updated>1686758043695</updated>
175
- </task>
176
- <task id="LOCAL-00012" summary="Add remaining column mappings">
177
- <created>1686758202293</created>
178
- <option name="number" value="00012" />
179
- <option name="presentableId" value="LOCAL-00012" />
180
- <option name="project" value="LOCAL" />
181
- <updated>1686758202293</updated>
182
- </task>
183
- <option name="localTasksCounter" value="13" />
184
- <servers />
185
- </component>
186
- <component name="TypeScriptGeneratedFilesManager">
187
- <option name="version" value="3" />
188
- </component>
189
- <component name="Vcs.Log.Tabs.Properties">
190
- <option name="TAB_STATES">
191
- <map>
192
- <entry key="MAIN">
193
- <value>
194
- <State />
195
- </value>
196
- </entry>
197
- </map>
198
- </option>
199
- <option name="oldMeFiltersMigrated" value="true" />
200
- </component>
201
- <component name="VcsManagerConfiguration">
202
- <MESSAGE value="Remove eslint" />
203
- <MESSAGE value="Add -cf flag to generate-suggestions" />
204
- <MESSAGE value="Remove redundant variable" />
205
- <MESSAGE value="Add command to show component-folders" />
206
- <MESSAGE value="Command description" />
207
- <MESSAGE value="Stringify print" />
208
- <MESSAGE value="Add import-component function" />
209
- <MESSAGE value="simplify generate-suggestions flag passing" />
210
- <MESSAGE value="Add import-components command" />
211
- <MESSAGE value="Add flag check for csv files" />
212
- <MESSAGE value="Add (.csv format only)" />
213
- <MESSAGE value="Add remaining column mappings" />
214
- <option name="LAST_COMMIT_MESSAGE" value="Add remaining column mappings" />
215
- </component>
216
- <component name="XSLT-Support.FileAssociations.UIState">
217
- <expand />
218
- <select />
219
- </component>
220
- </project>