diff --git a/.github/workflows/cli-test.yml b/.github/workflows/cli-test.yml new file mode 100644 index 0000000..d213e68 --- /dev/null +++ b/.github/workflows/cli-test.yml @@ -0,0 +1,71 @@ +name: xdpm CI + +on: [push] + +jobs: + mac: + runs-on: macos-latest + strategy: + matrix: + node-version: [8.x, 10.x, 12.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm link + - run: xdpm -v + - run: xdpm validate + continue-on-error: true + - run: xdpm package + continue-on-error: true + - run: mkdir -p /Users/runner/Library/Application\ Support/Adobe/Adobe\ XD + - run: xdpm install + continue-on-error: true + - run: git clone https://github.com/AdobeXD/plugin-samples.git + - run: xdpm validate + working-directory: ./plugin-samples/quick-start + - run: xdpm package + working-directory: ./plugin-samples/quick-start + - run: echo "{}" > ./manifest.json + working-directory: ./plugin-samples/quick-start + - run: xdpm validate + working-directory: ./plugin-samples/quick-start + continue-on-error: true + + windows: + runs-on: windows-latest + + strategy: + matrix: + node-version: [8.x, 10.x, 12.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm link + - run: xdpm -v + - run: xdpm validate + continue-on-error: true + - run: xdpm package + continue-on-error: true + - run: md C:\Users\runneradmin\AppData\Local\Packages\Adobe.CC.XD_adky2gkssdxte\LocalState + - run: xdpm install + continue-on-error: true + - run: git clone https://github.com/AdobeXD/plugin-samples.git + - run: xdpm validate + working-directory: ./plugin-samples/quick-start + - run: xdpm package + working-directory: ./plugin-samples/quick-start + - run: echo "{}" > ./manifest.json + working-directory: ./plugin-samples/quick-start + - run: xdpm validate + working-directory: ./plugin-samples/quick-start + continue-on-error: true diff --git a/lib/manifestSchema.js b/lib/manifestSchema.js index ef9b1e1..7395f9a 100644 --- a/lib/manifestSchema.js +++ b/lib/manifestSchema.js @@ -1,5 +1,5 @@ const manifestScema = { - required: ["id", "name", "version", "host", "uiEntryPoints"], + required: ["id", "name", "version", "icons", "host", "uiEntryPoints"], properties: { id: { type: "string", @@ -20,6 +20,7 @@ const manifestScema = { minItems: 2, uniqueItems: true, items: { + type: "object", required: ["path", "width", "height"], properties: { path: { diff --git a/lib/validate.js b/lib/validate.js index bd02e7f..799f212 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -24,23 +24,29 @@ function validate(manifest, { root, id } = {}) { let errors = []; var validate = ajv.compile(manifestScema); var valid = validate(manifest); + if ( id && manifest.id !== id ) { errors.push( `F1001: Manifest 'id' does not match expected id. Saw '${manifest.id}', expected '${id}'.` ); } + if (!valid) { errors = validate.errors.map( e => `${e.dataPath} (${JSON.stringify(e.params)}) -> ${e.message} ` ); } - manifest.icons.forEach((icon, idx) => { - if (!fs.existsSync(path.join(root || ".", icon.path))) { - errors.push( - `W2004: Icon ${idx} has path ${icon.path}, but no icon was found there.` - ); - } - }); + + if (manifest.icons) { + manifest.icons.forEach((icon, idx) => { + if (!fs.existsSync(path.join(root || ".", icon.path))) { + errors.push( + `W2004: Icon ${idx} has path ${icon.path}, but no icon was found there.` + ); + } + }); + } + return errors; }