Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/alpha' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypkhantc committed Apr 23, 2024
2 parents 86cc00a + f7c7618 commit 2aab404
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [1.0.0-alpha.4](https://github.com/tenantcloud/template-sync/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2024-04-23)


### Bug Fixes

* Error message ([605e3ee](https://github.com/tenantcloud/template-sync/commit/605e3eea3c36e8643e836103bee4abdfff677c2e))

# [1.0.0-alpha.3](https://github.com/tenantcloud/template-sync/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2024-04-22)


Expand Down
53 changes: 36 additions & 17 deletions dist/github-action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52909,18 +52909,21 @@ async function writeJson(path, obj) {
await (0,external_fs_promises_namespaceObject.writeFile)(path, JSON.stringify(obj));
}

// EXTERNAL MODULE: ./node_modules/fs-extra/lib/index.js
var lib = __nccwpck_require__(5630);
;// CONCATENATED MODULE: ./src/config.ts



const configSchema = z.strictObject({

const sourceConfigSchema = z.strictObject({
repositories: z.array(z.strictObject({
url: z.string().min(1),
branch: z.string().min(1),
}))
.min(1),
});
const pluginsConfigSchema = z.strictObject({
const templateConfigSchema = z.strictObject({
plugins: z.array(z.union([
z.string().min(1),
z.object({
Expand All @@ -52930,19 +52933,35 @@ const pluginsConfigSchema = z.strictObject({
]))
.min(1),
});
const CONFIG_FILE_NAME = "template-sync.json";
async function loadConfig(root) {
const rawConfig = await readJson((0,external_path_.join)(root, CONFIG_FILE_NAME));
return configSchema.parse(rawConfig);
}
const PLUGINS_CONFIG_FILE_NAME = "template-sync.plugins.json";
async function loadPluginsConfig(root) {
const rawConfig = await readJson((0,external_path_.join)(root, PLUGINS_CONFIG_FILE_NAME));
return pluginsConfigSchema.parse(rawConfig);
const SOURCE_CONFIG_FILE_NAME = "template-sync.json";
const POSSIBLE_SOURCE_CONFIG_FILE_NAMES = [
SOURCE_CONFIG_FILE_NAME,
".github/" + SOURCE_CONFIG_FILE_NAME,
];
async function loadSourceConfig(root) {
const rawConfig = await loadConfigFromPossible(root, POSSIBLE_SOURCE_CONFIG_FILE_NAMES);
return sourceConfigSchema.parse(rawConfig);
}
const TEMPLATE_CONFIG_FILE_NAME = "template-sync.template.json";
const POSSIBLE_TEMPLATE_CONFIG_FILE_NAMES = [
TEMPLATE_CONFIG_FILE_NAME,
".github/" + TEMPLATE_CONFIG_FILE_NAME,
];
async function loadTemplateConfig(root) {
const rawConfig = await loadConfigFromPossible(root, POSSIBLE_TEMPLATE_CONFIG_FILE_NAMES);
return templateConfigSchema.parse(rawConfig);
}
async function loadConfigFromPossible(root, possibleFileNames) {
for (const fileName of possibleFileNames) {
const path = (0,external_path_.join)(root, fileName);
if (!(await (0,lib.pathExists)(path))) {
continue;
}
return await readJson(path);
}
throw new Error("Could not find config.");
}

// EXTERNAL MODULE: ./node_modules/fs-extra/lib/index.js
var lib = __nccwpck_require__(5630);
;// CONCATENATED MODULE: ./src/plugins/standard/sync.ts


Expand Down Expand Up @@ -53038,13 +53057,13 @@ async function loadPluginFactory(name, repositoryRoot) {


async function sync_sync(sourceRoot, { repositoryCloner, }) {
const sourceConfig = await loadConfig(sourceRoot);
const sourceConfig = await loadSourceConfig(sourceRoot);
const source = new Repository(sourceRoot);
let reserved = [PLUGINS_CONFIG_FILE_NAME];
let reserved = [...POSSIBLE_TEMPLATE_CONFIG_FILE_NAMES];
for (const repositoryConfig of sourceConfig.repositories) {
const template = await repositoryCloner.clone(repositoryConfig.url, repositoryConfig.branch);
const pluginsConfig = await loadPluginsConfig(template.root);
for (const pluginConfig of pluginsConfig.plugins) {
const templateConfig = await loadTemplateConfig(template.root);
for (const pluginConfig of templateConfig.plugins) {
const plugin = await loadPlugin(pluginConfig, template.root);
const { reserved: pluginReserved } = await plugin(template, source, reserved);
reserved = reserved.concat(...pluginReserved);
Expand Down

0 comments on commit 2aab404

Please sign in to comment.