Skip to content

Commit a5c1f0b

Browse files
authored
[admin] Update packages and remove yarn references (#998)
* Update packages and remove yarn references * Remove undefined author additions * Allow empty template and style sections for custom functions snippets * Update yaml package
1 parent 43b853a commit a5c1f0b

File tree

332 files changed

+1554
-2571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

332 files changed

+1554
-2571
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ A collection of code snippets built with [Script Lab](//github.com/OfficeDev/scr
1313
1. [Fork](https://help.github.com/articles/about-forks/) this project into your GitHub account.
1414
1. Clone your fork to your development computer.
1515
1. Ensure that you have Node, version 6.10+, installed. (To check the version run the command `node -v`.)
16-
1. Install `yarn` as a global package `npm install yarn --global`.
17-
1. Be sure your CLI is in the root of the office-js-snippets repo and run `yarn install`. (It's similar to `npm install`.)
16+
1. Be sure your CLI is in the root of the office-js-snippets repo and run `npm install` to install all dependencies.
1817
1. Set up the original \OfficeDev\office-js-snippets as the upstream repo for your local repo by following the steps in [Configuring a remote for a fork](https://help.github.com/articles/configuring-a-remote-for-a-fork/).
1918
1. If you'll be using Visual Studio Code as your editor, install the [TSLint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint) extension for Visual Studio Code.
2019

@@ -46,11 +45,11 @@ A collection of code snippets built with [Script Lab](//github.com/OfficeDev/scr
4645

4746
1. Open one of the `.yaml` files already in the group folder. If it has an `order` property near the top, then the snippets in the group folder are ordered in a particular sequence in Script Lab. Add an `order` property to the top of your `.yaml` file and give it a number that is between the order numbers of the snippets between which you want it to appear.
4847
1. Copy your `.yaml` file to the chosen group folder.
49-
1. Run `yarn start`. If there are no problems, the output will end with a `Done!`. If there are errors, review the output to check what caused the build validation to fail, and fix as needed. See [**Known errors and fixes**](#known-errors-and-fixes-in-the-build-tool) for more information.
48+
1. Run `npm start`. If there are no problems, the output will end with a `Done!`. If there are errors, review the output to check what caused the build validation to fail, and fix as needed. See [**Known errors and fixes**](#known-errors-and-fixes-in-the-build-tool) for more information.
5049

51-
> **Note**: The `yarn start` command adds an `id` property to the top of the file.
50+
> **Note**: The `npm start` command adds an `id` property to the top of the file.
5251

53-
1. Re-run `yarn start`, and fix errors, until the build succeeds.
52+
1. Re-run `npm start`, and fix errors, until the build succeeds.
5453
1. Run `git status`. You should see that, in addition to your new `.yaml` file (or possibly new folder), a `playlist\{host}.yaml` file (where `{host}` is `excel`, `word`, etc.) has also been changed. This is expected. The build tool you just ran added a reference to your new snippet to this file.
5554
1. Run the following two commands. The commit message should be a brief description of what the snippet demonstrates; for example, `"shows how to use getWhatever method"`.
5655

config/build.documentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function buildReferenceDocSnippetExtracts(
3636
await rmRf('snippet-extractor-output');
3737
await mkDir('snippet-extractor-output');
3838

39-
const contents = snippetExtractsPerHost.map(extracts => jsyaml.safeDump(extracts)).join('');
39+
const contents = snippetExtractsPerHost.map(extracts => jsyaml.dump(extracts)).join('');
4040
await writeFile(path.resolve(`snippet-extractor-output/snippets.yaml`), contents);
4141
}
4242

@@ -119,7 +119,7 @@ function getExtractedDataFromSnippet(
119119
const filename = snippetIdsToFilenames[row.snippetId];
120120
if (filename) {
121121
try {
122-
const script = (jsyaml.safeLoad(fs.readFileSync(filename).toString()) as ISnippet).script.content;
122+
const script = (jsyaml.load(fs.readFileSync(filename).toString()) as ISnippet).script.content;
123123

124124
const fullSnippetTextArray = script.split('\n')
125125
.map(line => line.replace(/\r/, ''));

config/build.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import * as path from 'path';
44
import { isNil, isString, isArray, isEmpty, sortBy, cloneDeep } from 'lodash';
5-
import * as chalk from 'chalk';
5+
import chalk from 'chalk';
6+
import escapeStringRegexp from 'escape-string-regexp';
67
import { status } from './status';
78
import {
89
SnippetFileInput, SnippetProcessedData,
@@ -14,7 +15,6 @@ import { getShareableYaml } from './snippet.helpers';
1415
import { processLibraries } from './libraries.processor';
1516
import { startCase, groupBy, map } from 'lodash';
1617
import * as jsyaml from 'js-yaml';
17-
import escapeStringRegexp = require('escape-string-regexp');
1818
import * as fsx from 'fs-extra';
1919

2020

@@ -84,7 +84,7 @@ async function processSnippets(processedSnippets: Dictionary<SnippetProcessedDat
8484

8585
const fullPath = path.resolve(dir, file.relativePath);
8686
const originalFileContents = fsx.readFileSync(fullPath).toString().trim();
87-
let snippet = jsyaml.safeLoad(originalFileContents) as ISnippet;
87+
let snippet = jsyaml.load(originalFileContents) as ISnippet;
8888

8989
// Do validations & auto-corrections
9090
validateStringFieldNotEmptyOrThrow(snippet, 'name');
@@ -103,7 +103,11 @@ async function processSnippets(processedSnippets: Dictionary<SnippetProcessedDat
103103
const additionalFields: ISnippet = <any>{};
104104
additionalFields.id = snippet.id;
105105
additionalFields.api_set = snippet.api_set;
106-
additionalFields.author = snippet.author;
106+
107+
// Only set author field if it has a value
108+
if (snippet.author) {
109+
additionalFields.author = snippet.author;
110+
}
107111

108112
if ((typeof (snippet as any).order) !== 'undefined') {
109113
// # for ordering, if present (used for samples only)
@@ -537,7 +541,7 @@ async function generatePlaylists(processedSnippets: Dictionary<SnippetProcessedD
537541
};
538542
});
539543

540-
let contents = jsyaml.safeDump(modifiedItems, {
544+
let contents = jsyaml.dump(modifiedItems, {
541545
skipInvalid: true /* skip "undefined" (e.g., for "order" on some of the snippets) */
542546
});
543547

config/helpers.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as path from 'path';
22
import * as fs from 'fs';
33
import * as os from 'os';
4-
import * as chalk from 'chalk';
4+
import chalk from 'chalk';
55
import * as jsyaml from 'js-yaml';
66
import { console } from './status';
7-
import * as rimraf from 'rimraf';
7+
import { rimraf } from 'rimraf';
88
import { isObject, isNil, isString, isEmpty } from 'lodash';
99

1010
export interface SnippetFileInput {
@@ -39,7 +39,7 @@ export interface SnippetProcessedData {
3939
* @param message Message of the banner.
4040
* @param chalkFunction Chalk color function.
4141
*/
42-
export const banner = (title: string, message: string = null, chalkFn: chalk.ChalkChain = null) => {
42+
export const banner = (title: string, message: string = null, chalkFn: any = null) => {
4343
if (!chalkFn) {
4444
chalkFn = chalk.bold;
4545
}
@@ -55,7 +55,7 @@ export const banner = (title: string, message: string = null, chalkFn: chalk.Cha
5555
};
5656

5757
export function getPrintableDetails(item: any, indent: number) {
58-
const details = jsyaml.safeDump(item, {
58+
const details = jsyaml.dump(item, {
5959
indent: 4,
6060
lineWidth: -1,
6161
skipInvalid: true
@@ -83,16 +83,11 @@ export const mkDir = (dir: string) =>
8383
* Deletes a folder.
8484
* @param dir An absolute path to the directory.
8585
*/
86-
export const rmRf = (dir: string) =>
87-
new Promise<string>((resolve, reject) => {
88-
const location = path.resolve(dir);
89-
rimraf(location, (err) => {
90-
if (err) {
91-
return reject(err);
92-
}
93-
return resolve(location);
94-
});
95-
});
86+
export const rmRf = async (dir: string): Promise<string> => {
87+
const location = path.resolve(dir);
88+
await rimraf(location);
89+
return location;
90+
};
9691

9792
/**
9893
* Load all the files and folders in a given directory.

config/snippet.helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function scrubCarriageReturns(snippet: ISnippet) {
9191
export function getScrubbedSnippet(snippet: ISnippet, keep: SnippetFieldType): ISnippet {
9292
let copy = {};
9393
forIn(snippetFields, (fieldType, fieldName) => {
94-
if (fieldType & keep) {
94+
if (fieldType & keep && snippet[fieldName] !== undefined) {
9595
copy[fieldName] = snippet[fieldName];
9696
}
9797
});
@@ -103,7 +103,7 @@ export function getShareableYaml(rawSnippet: ISnippet, additionalFields: ISnippe
103103
const snippet = { ...getScrubbedSnippet(rawSnippet, SnippetFieldType.PUBLIC), ...additionalFields };
104104
scrubCarriageReturns(snippet);
105105

106-
return jsyaml.safeDump(snippet, {
106+
return jsyaml.dump(snippet, {
107107
indent: 4,
108108
lineWidth: -1,
109109
sortKeys: <any>((a, b) => snippetFieldSortingOrder[a] - snippetFieldSortingOrder[b]),

config/status.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as nodeStatus from 'node-status';
2-
import * as chalk from 'chalk';
2+
import chalk from 'chalk';
33
import { isString, find, isNil, isArray } from 'lodash';
44

55
interface IStage {

package.json

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,23 @@
2323
},
2424
"homepage": "https://github.com/OfficeDev/office-js-snippets#readme",
2525
"dependencies": {
26-
"chalk": "1.1.3",
27-
"escape-string-regexp": "^2.0.0",
28-
"exceljs": "^4.3.0",
29-
"fs-extra": "3.0.1",
30-
"js-yaml": "^3.13.1",
26+
"chalk": "^4.1.2",
27+
"escape-string-regexp": "^4.0.0",
28+
"exceljs": "^4.4.0",
29+
"fs-extra": "11.3.2",
30+
"js-yaml": "^4.1.0",
3131
"lodash": "^4.17.21",
3232
"node-status": "^1.0.0",
33-
"rimraf": "^3.0.0",
34-
"shelljs": "^0.8.5",
35-
"yarn": "^1.22.19"
33+
"rimraf": "^6.0.1",
34+
"shelljs": "^0.10.0"
3635
},
3736
"devDependencies": {
38-
"@types/chalk": "0.4.31",
39-
"@types/fs-extra": "3.0.1",
40-
"@types/js-yaml": "^3.12.0",
41-
"@types/lodash": "^4.14.175",
42-
"@types/node": "^11.10.5",
43-
"@types/shelljs": "^0.8.3",
44-
"tslint": "^6.1.0",
45-
"typescript": "^3.3.3333"
37+
"@types/fs-extra": "^11.0.4",
38+
"@types/js-yaml": "^4.0.9",
39+
"@types/lodash": "^4.17.20",
40+
"@types/node": "^24.5.2",
41+
"@types/shelljs": "^0.8.17",
42+
"tslint": "^6.1.3",
43+
"typescript": "^5.9.2"
4644
}
4745
}

playlists-prod/excel.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
- id: excel-chart-axis
3131
name: Axis details
3232
fileName: chart-axis.yaml
33-
description: 'Gets, sets, and removes axis unit, label, and title in a chart.'
33+
description: Gets, sets, and removes axis unit, label, and title in a chart.
3434
rawUrl: >-
3535
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-axis.yaml
3636
group: Chart
@@ -162,7 +162,7 @@
162162
- id: excel-chart-trendlines
163163
name: Trendlines
164164
fileName: chart-trendlines.yaml
165-
description: 'Adds, gets, and formats trendlines in a chart.'
165+
description: Adds, gets, and formats trendlines in a chart.
166166
rawUrl: >-
167167
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-trendlines.yaml
168168
group: Chart
@@ -189,7 +189,7 @@
189189
- id: excel-comment-basics
190190
name: Comment basics
191191
fileName: comment-basics.yaml
192-
description: 'Adds, edits, and removes comments.'
192+
description: Adds, edits, and removes comments.
193193
rawUrl: >-
194194
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml
195195
group: Comments And Notes
@@ -207,7 +207,7 @@
207207
- id: excel-comment-replies
208208
name: Comment replies
209209
fileName: comment-replies.yaml
210-
description: 'Adds, edits, and removes comment replies.'
210+
description: Adds, edits, and removes comment replies.
211211
rawUrl: >-
212212
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml
213213
group: Comments And Notes
@@ -225,7 +225,7 @@
225225
- id: excel-note-basics
226226
name: Notes
227227
fileName: excel-note-basics.yaml
228-
description: 'Adds, edits, and removes notes.'
228+
description: Adds, edits, and removes notes.
229229
rawUrl: >-
230230
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml
231231
group: Comments And Notes
@@ -319,7 +319,7 @@
319319
- id: excel-custom-xml-parts-create-set-get-and-delete-custom-xml-parts
320320
name: Using custom XML parts
321321
fileName: create-set-get-and-delete-custom-xml-parts.yaml
322-
description: 'Creates, sets, gets, and deletes a custom XML part.'
322+
description: Creates, sets, gets, and deletes a custom XML part.
323323
rawUrl: >-
324324
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml
325325
group: Custom XML Parts
@@ -625,9 +625,9 @@
625625
api_set:
626626
ExcelAPI: '1.14'
627627
- id: excel-named-item-create-and-remove-named-item
628-
name: 'Create, access, and remove'
628+
name: Create, access, and remove
629629
fileName: create-and-remove-named-item.yaml
630-
description: 'Creates, accesses, and removes named items in a worksheet.'
630+
description: Creates, accesses, and removes named items in a worksheet.
631631
rawUrl: >-
632632
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/34-named-item/create-and-remove-named-item.yaml
633633
group: Named Item
@@ -785,16 +785,16 @@
785785
- id: excel-range-hyperlink
786786
name: Hyperlinks
787787
fileName: range-hyperlink.yaml
788-
description: 'Creates, updates, and clears hyperlinks in a range.'
788+
description: Creates, updates, and clears hyperlinks in a range.
789789
rawUrl: >-
790790
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml
791791
group: Range
792792
api_set:
793793
ExcelApi: '1.7'
794794
- id: excel-range-insert-delete-and-clear-range
795-
name: 'Insert, delete, and clear'
795+
name: Insert, delete, and clear
796796
fileName: insert-delete-clear-range.yaml
797-
description: 'Inserts, deletes, and clears a range.'
797+
description: Inserts, deletes, and clears a range.
798798
rawUrl: >-
799799
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/insert-delete-clear-range.yaml
800800
group: Range
@@ -1217,9 +1217,9 @@
12171217
api_set:
12181218
ExcelApi: '1.1'
12191219
- id: excel-worksheet-add-delete-rename-move-worksheet
1220-
name: 'Add, delete, rename, and move worksheet'
1220+
name: Add, delete, rename, and move worksheet
12211221
fileName: add-delete-rename-move-worksheet.yaml
1222-
description: 'Adds, deletes, renames, and moves a worksheet.'
1222+
description: Adds, deletes, renames, and moves a worksheet.
12231223
rawUrl: >-
12241224
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml
12251225
group: Worksheet

playlists-prod/outlook.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
- id: outlook-roaming-settings-roaming-settings
22
name: Use add-in settings
33
fileName: roaming-settings.yaml
4-
description: 'Gets, sets, saves, and removes add-in roaming settings.'
4+
description: Gets, sets, saves, and removes add-in roaming settings.
55
rawUrl: >-
66
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/10-roaming-settings/roaming-settings.yaml
77
group: Roaming Settings
@@ -295,7 +295,7 @@
295295
- id: outlook-categories-work-with-categories
296296
name: Work with item categories
297297
fileName: work-with-categories.yaml
298-
description: 'Gets, adds, and removes categories assigned to the item.'
298+
description: Gets, adds, and removes categories assigned to the item.
299299
rawUrl: >-
300300
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml
301301
group: Categories
@@ -304,7 +304,7 @@
304304
- id: outlook-categories-work-with-master-categories
305305
name: Work with the categories master list
306306
fileName: work-with-master-categories.yaml
307-
description: 'Gets, adds, and removes categories in the master list for the mailbox.'
307+
description: Gets, adds, and removes categories in the master list for the mailbox.
308308
rawUrl: >-
309309
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml
310310
group: Categories
@@ -447,7 +447,7 @@
447447
api_set:
448448
Mailbox: '1.8'
449449
- id: outlook-regex-matches-contextual
450-
name: 'Get regex matches (Item Read, contextual)'
450+
name: Get regex matches (Item Read, contextual)
451451
fileName: contextual.yaml
452452
description: Gets regex matches when the add-in is opened as a contextual add-in.
453453
rawUrl: >-
@@ -639,7 +639,7 @@
639639
- id: outlook-other-item-apis-get-add-remove-enhancedlocation-appointment
640640
name: Manage the locations of an appointment
641641
fileName: get-add-remove-enhancedlocation-appointment.yaml
642-
description: 'Gets, adds, and removes locations on an appointment (enhancedLocation API).'
642+
description: Gets, adds, and removes locations on an appointment (enhancedLocation API).
643643
rawUrl: >-
644644
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml
645645
group: Other Item APIs
@@ -704,7 +704,7 @@
704704
- id: outlook-other-item-apis-session-data-apis
705705
name: Work with session data APIs (Compose)
706706
fileName: session-data-apis.yaml
707-
description: 'Sets, gets, gets all, removes, and clears session data in Compose mode.'
707+
description: Sets, gets, gets all, removes, and clears session data in Compose mode.
708708
rawUrl: >-
709709
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml
710710
group: Other Item APIs
@@ -720,7 +720,7 @@
720720
api_set:
721721
Mailbox: '1.13'
722722
- id: outlook-other-item-apis-get-message-properties
723-
name: 'Get properties of selected messages (Message Compose, Message Read)'
723+
name: Get properties of selected messages (Message Compose, Message Read)
724724
fileName: get-message-properties.yaml
725725
description: Gets the properties of multiple selected messages.
726726
rawUrl: >-
@@ -794,7 +794,7 @@
794794
api_set:
795795
Mailbox: '1.15'
796796
- id: outlook-other-item-apis-get-loaded-message-properties
797-
name: 'Get properties of a loaded message (Message Compose, Message Read)'
797+
name: Get properties of a loaded message (Message Compose, Message Read)
798798
fileName: get-loaded-message-properties.yaml
799799
description: Gets the properties of the currently loaded message.
800800
rawUrl: >-

0 commit comments

Comments
 (0)