Skip to content

Commit

Permalink
ci: update formVersionWriter to be able to read the internal compon…
Browse files Browse the repository at this point in the history
…ent's version
  • Loading branch information
sun-mota committed Nov 29, 2024
1 parent 3c8a446 commit b2e6123
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/combobox/src/auro-combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { AuroDropdown } from '@aurodesignsystem/auro-dropdown/src/auro-dropdown.
import dropdownVersion from '../../../src/dropdownVersion.js';

import { AuroInput } from '../../input/src/auro-input.js';
import inputVersion from '../../../src/form/components/inputVersion.js';
import inputVersion from '../../../src/internal/inputVersion.js';

// Import touch detection lib
import styleCss from "./style-css.js";
Expand Down
2 changes: 1 addition & 1 deletion components/combobox/src/scripts/version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { writeDepVersionFile } from '../../../../scripts/formVersionWriter.js'
import path from "node:path";

writeDepVersionFile('@aurodesignsystem/auro-dropdown');
writeDepVersionFile(path.resolve('./components/input'));
writeDepVersionFile('@/components/input');
2 changes: 1 addition & 1 deletion components/datepicker/src/auro-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { AuroDropdown } from '@aurodesignsystem/auro-dropdown/src/auro-dropdown.
import dropdownVersion from '../../../src/dropdownVersion.js';

import { AuroInput } from '../../input/src/auro-input.js';
import inputVersion from '../../../src/form/components/inputVersion.js';
import inputVersion from '../../../src/internal/inputVersion.js';

// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
/**
Expand Down
2 changes: 1 addition & 1 deletion components/datepicker/src/scripts/version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import path from "node:path";

writeDepVersionFile('@aurodesignsystem/auro-popover');
writeDepVersionFile('@aurodesignsystem/auro-dropdown');
writeDepVersionFile(path.resolve(process.cwd(), './components/input'));
writeDepVersionFile('@/components/input');

2 changes: 1 addition & 1 deletion components/select/src/scripts/version.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { writeDepVersionFile } from '../../../../scripts/formVersionWriter.js'

writeDepVersionFile('@aurodesignsystem/auro-dropdown');
writeDepVersionFile('@aurodesignsystem/auro-dropdown');
14 changes: 10 additions & 4 deletions scripts/formVersionWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ---------------------------------------------------------------------
import { createRequire } from 'module';
import { mkdir, writeFile, existsSync } from 'fs';
import { dirname } from 'path';
import path, { dirname } from 'path';
import { fileURLToPath } from 'url';

const require = createRequire(import.meta.url);
Expand All @@ -14,10 +14,16 @@ const auroSubNameIndex = 5;
* @param {string} pkg Dependency to write version file for
*/
export function writeDepVersionFile(pkg) {
const path = `${pkg}/package.json`;
const json = require(path);
let pkgPath = pkg;
const interanlRegex = /^\@\/components/;
const isInternal = !!pkg.match(interanlRegex);
if (isInternal) {
pkgPath = path.resolve(process.cwd(), pkg.replace("@", "."));
}
const packageJsonPath = `${pkgPath}/package.json`;
const json = require(packageJsonPath);
const { version } = json;
const elemSubName = pkg.substring(pkg.indexOf('auro-') + auroSubNameIndex);
const elemSubName = isInternal ? 'internal/' + pkg.replace(interanlRegex, "").replace("/", "") : pkg.substring(pkg.indexOf('auro-') + auroSubNameIndex);

// Get the calling file's path
const callerPath = fileURLToPath(import.meta.url);
Expand Down
File renamed without changes.

0 comments on commit b2e6123

Please sign in to comment.