@the-vcsi/msgraph 0.0.3 → 0.0.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 (2) hide show
  1. package/package.json +15 -4
  2. package/src/index.js +16 -4
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "@the-vcsi/msgraph",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "sv CLI add-on for Microsoft Graph / SharePoint integration",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": "./src/index.js"
8
8
  },
9
- "files": ["src"],
10
- "keywords": ["sv-add", "svelte", "sveltekit", "microsoft-graph", "sharepoint"],
9
+ "files": [
10
+ "src"
11
+ ],
12
+ "keywords": [
13
+ "sv-add",
14
+ "svelte",
15
+ "sveltekit",
16
+ "microsoft-graph",
17
+ "sharepoint"
18
+ ],
11
19
  "dependencies": {},
12
20
  "peerDependencies": {
13
21
  "sv": "^0.13.0"
@@ -16,5 +24,8 @@
16
24
  "type": "git",
17
25
  "url": "https://github.com/Vermont-Complex-Systems/vcsi-starter"
18
26
  },
19
- "license": "MIT"
27
+ "license": "MIT",
28
+ "scripts": {
29
+ "test": "node --test test/"
30
+ }
20
31
  }
package/src/index.js CHANGED
@@ -18,6 +18,17 @@ const options = defineAddonOptions()
18
18
  })
19
19
  .build();
20
20
 
21
+ // sv.file hands us the file's current contents, or nothing when it does not
22
+ // exist yet. Everything this add-on writes is edited afterwards: appSettings.js
23
+ // carries the siteId, fetch-assets.js carries ASSET_FOLDERS, and either fetch
24
+ // script may be tuned per site. So a re-run must leave an existing file alone.
25
+ //
26
+ // `sv add` scaffolds a project; it does not update one. To adopt a newer
27
+ // version of these scripts, diff this package's templates against your copy and
28
+ // port the change deliberately.
29
+ const keepExisting = (generated) => (content) =>
30
+ content && content.trim() ? content : generated;
31
+
21
32
  export default defineAddon({
22
33
  id: '@the-vcsi/msgraph',
23
34
  shortDescription: 'Microsoft Graph / SharePoint integration for fetching story content',
@@ -25,14 +36,14 @@ export default defineAddon({
25
36
 
26
37
  run: ({ sv, options: opts }) => {
27
38
  // Create the fetch script
28
- sv.file('scripts/fetch-msgraph.js', () => FETCH_SCRIPT);
39
+ sv.file('scripts/fetch-msgraph.js', keepExisting(FETCH_SCRIPT));
29
40
 
30
41
  // Pull binary assets (headshots, logos) out of the same SharePoint site
31
- sv.file('scripts/fetch-assets.js', () => ASSETS_SCRIPT);
42
+ sv.file('scripts/fetch-assets.js', keepExisting(ASSETS_SCRIPT));
32
43
 
33
44
  // Create app settings config with user-provided siteId
34
45
  const appSettings = APP_SETTINGS.replace(/__SITE_ID__/g, opts.siteId || 'YOUR_SITE_ID');
35
- sv.file('src/appSettings.js', () => appSettings);
46
+ sv.file('src/appSettings.js', keepExisting(appSettings));
36
47
 
37
48
  // Append to .env.example (or create if doesn't exist)
38
49
  sv.file('.env.example', (content) => {
@@ -67,6 +78,7 @@ export default defineAddon({
67
78
  'Get credentials from Azure Portal > App registrations',
68
79
  'Run npm install',
69
80
  'Run npm run fetch:sharepoint to pull story copy',
70
- 'Run npm run fetch:headshots to pull images (edit ASSET_FOLDERS first)'
81
+ 'Run npm run fetch:headshots to pull images (edit ASSET_FOLDERS first)',
82
+ 'Re-running this add-on keeps any of these files you already have'
71
83
  ]
72
84
  });