Skip to content

Commit

Permalink
Deploy (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
jotanarciso authored Aug 13, 2024
2 parents 3c52aa2 + dee3055 commit 26fee53
Show file tree
Hide file tree
Showing 38 changed files with 4,323 additions and 2,636 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
## [3.1.0-stage.5](https://github.com/aziontech/vulcan/compare/v3.1.0-stage.4...v3.1.0-stage.5) (2024-08-09)


### Features

* enable writeFile, rename and realpath from Node FS ([#369](https://github.com/aziontech/vulcan/issues/369)) ([a219a57](https://github.com/aziontech/vulcan/commit/a219a57ec84ad4c5efaaacef8c9ffb7d3a78f3c0))

## [3.1.0-stage.4](https://github.com/aziontech/vulcan/compare/v3.1.0-stage.3...v3.1.0-stage.4) (2024-08-09)


### Features

* added purge parameters to the manifest ([#368](https://github.com/aziontech/vulcan/issues/368)) ([a006b50](https://github.com/aziontech/vulcan/commit/a006b5021f9d9f5116bfbdaf7c247949e2b58024))

## [3.1.0-stage.3](https://github.com/aziontech/vulcan/compare/v3.1.0-stage.2...v3.1.0-stage.3) (2024-08-08)


### Features

* support azion.config with TypeScript ([#362](https://github.com/aziontech/vulcan/issues/362)) ([67ba4fe](https://github.com/aziontech/vulcan/commit/67ba4fe2352edd21cd2653cc3f6b63fd9739dd8f))

## [3.1.0-stage.2](https://github.com/aziontech/vulcan/compare/v3.1.0-stage.1...v3.1.0-stage.2) (2024-08-07)


### Features

* added all origins parameters to the manifest ([#367](https://github.com/aziontech/vulcan/issues/367)) ([b0ee08b](https://github.com/aziontech/vulcan/commit/b0ee08bd0c931fe6185b1ccce13b4e08a70d0928))

## [3.1.0-stage.1](https://github.com/aziontech/vulcan/compare/v3.0.0...v3.1.0-stage.1) (2024-08-02)


### Features

* adding support for domains in manifest generation. ([#366](https://github.com/aziontech/vulcan/issues/366)) ([7223c84](https://github.com/aziontech/vulcan/commit/7223c84c0121dd90026919874d3d520537b5325d))

## [3.0.0](https://github.com/aziontech/vulcan/compare/v2.12.1...v3.0.0) (2024-07-29)


Expand Down
43 changes: 37 additions & 6 deletions lib/build/dispatcher/dispatcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { join, resolve, dirname, extname } from 'path';
import { readFileSync, existsSync, writeFileSync, rmSync } from 'fs';
import {
readFileSync,
existsSync,
writeFileSync,
rmSync,
unlinkSync,
} from 'fs';
import { transpileModule } from 'typescript';
import { Esbuild, Webpack } from '#bundlers';
import {
feedback,
Expand Down Expand Up @@ -565,14 +572,38 @@ class Dispatcher {
const azionConfigAlreadyExists = !!azionConfigPath;

let configModule = null;

if (azionConfigAlreadyExists) {
const configModulePath = dirname(azionConfigPath);
const extension = extname(azionConfigPath);
configModule = await loadModule(
configModulePath,
'azion.config',
extension,
);

if (extension === '.ts') {
const tsContent = readFileSync(azionConfigPath, 'utf-8');
const jsContent = transpileModule(tsContent, {
compilerOptions: {
module: 'es2020',
target: 'es2020',
moduleResolution: 'node',
},
}).outputText;

const tempJsPath = azionConfigPath.replace('.ts', '.temp.mjs');
writeFileSync(tempJsPath, jsContent);

try {
configModule = await import(tempJsPath);
configModule = configModule.default || configModule;
} finally {
unlinkSync(tempJsPath);
}
}
if (extension !== '.ts') {
configModule = await loadModule(
configModulePath,
'azion.config',
extension,
);
}
}

if (!azionConfigAlreadyExists) {
Expand Down
14 changes: 7 additions & 7 deletions lib/build/dispatcher/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ function isCommonJS() {
}

/**
* Carrega dinamicamente um módulo com base no caminho, nome do arquivo e formato do arquivo.
* @param {string} inputpath - O caminho onde o módulo está localizado.
* @param {string} filename - O nome do arquivo do módulo sem a extensão.
* @param {string} format - O formato do arquivo (por exemplo, '.js', '.cjs', '.mjs').
* @returns {Promise<*>} O módulo importado ou null se nenhum módulo válido for encontrado.
* Dynamically loads a module based on the path, filename, and file format.
* @param {string} inputpath - The path where the module is located.
* @param {string} filename - The module's filename without the extension.
* @param {string} format - The file format (e.g., '.js', '.cjs', '.mjs').
* @returns {Promise<*>} The imported module or null if no valid module is found.
*/
async function loadModule(inputpath, filename, format) {
const modulePath = join(inputpath, `${filename}${format}`);
Expand All @@ -98,12 +98,12 @@ async function loadModule(inputpath, filename, format) {

/**
* Retrieves the path of the existing Azion configuration file in the current working directory.
* It checks for files with extensions '.js', '.mjs', or '.cjs'.
* It checks for files with extensions '.ts', '.js', '.mjs', or '.cjs'.
* @returns {Promise<string|null>} The path of the Azion configuration file if it exists, otherwise null.
*/
async function getAzionConfigPath() {
const rootPath = process.cwd();
const extensions = ['.js', '.mjs', '.cjs'];
const extensions = ['.ts', '.js', '.mjs', '.cjs'];
const filePath = extensions
.map((ext) => join(rootPath, `azion.config${ext}`))
.find((path) => existsSync(path));
Expand Down
6 changes: 6 additions & 0 deletions lib/env/polyfills/fs/context/fs.context.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const {
rmdir,
copyFile,
cp,
writeFile,
rename,
realpath,
Dir,
Dirent,
Stats,
Expand Down Expand Up @@ -64,6 +67,9 @@ localFs.mkdir = mkdir;
localFs.rmdir = rmdir;
localFs.copyFile = copyFile;
localFs.cp = cp;
localFs.writeFile = writeFile;
localFs.rename = rename;
localFs.realpath = realpath;
localFs.Dir = Dir;
localFs.Dirent = Dirent;
localFs.Stats = Stats;
Expand Down
22 changes: 22 additions & 0 deletions lib/env/polyfills/fs/fs.polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ function cp(src, dest, ...args) {
return FS_CONTEXT.cp(src, dest, ...args);
}

async function writeFile(path, data, ...args) {
path = `${BUILD_PATH_PREFIX}/${path}`;
return FS_CONTEXT.writeFile(path, data, ...args);
}

async function rename(src, dest, ...args) {
src = `${BUILD_PATH_PREFIX}/${src}`;
dest = `${BUILD_PATH_PREFIX}/${dest}`;
return FS_CONTEXT.rename(src, dest, ...args);
}

async function realpath(src, ...args) {
src = `${BUILD_PATH_PREFIX}/${src}`;
return FS_CONTEXT.realpath(src, ...args);
}

const constants = {
COPYFILE_EXCL: 1,
COPYFILE_FICLONE: 2,
Expand Down Expand Up @@ -158,6 +174,9 @@ export {
rmdir,
copyFile,
cp,
writeFile,
rename,
realpath,
constants,
F_OK,
O_APPEND,
Expand Down Expand Up @@ -197,6 +216,9 @@ localFs.mkdir = mkdir;
localFs.rmdir = rmdir;
localFs.copyFile = copyFile;
localFs.cp = cp;
localFs.writeFile = writeFile;
localFs.rename = rename;
localFs.realpath = realpath;
localFs.constants = constants;
localFs.F_OK = F_OK;
localFs.O_APPEND = O_APPEND;
Expand Down
22 changes: 22 additions & 0 deletions lib/env/polyfills/fs/promises.polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ async function cp(src, dest, ...args) {
return FS_CONTEXT.promises.cp(src, dest, ...args);
}

async function writeFile(path, data, ...args) {
path = `${BUILD_PATH_PREFIX}/${path}`;
return FS_CONTEXT.promises.writeFile(path, data, ...args);
}

async function rename(src, dest) {
src = `${BUILD_PATH_PREFIX}/${src}`;
dest = `${BUILD_PATH_PREFIX}/${dest}`;
return FS_CONTEXT.promises.rename(src, dest);
}

async function realpath(src, ...args) {
src = `${BUILD_PATH_PREFIX}/${src}`;
return FS_CONTEXT.promises.realpath(src, ...args);
}

const constants = {
COPYFILE_EXCL: 1,
COPYFILE_FICLONE: 2,
Expand Down Expand Up @@ -99,6 +115,9 @@ export {
copyFile,
cp,
constants,
writeFile,
rename,
realpath,
};

localFsPromises.open = open;
Expand All @@ -111,5 +130,8 @@ localFsPromises.rmdir = rmdir;
localFsPromises.copyFile = copyFile;
localFsPromises.cp = cp;
localFsPromises.constants = constants;
localFsPromises.writeFile = writeFile;
localFsPromises.rename = rename;
localFsPromises.realpath = realpath;

export default localFsPromises;
8 changes: 5 additions & 3 deletions lib/presets/angular/deliver/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

const config = AzionConfig({
origin: [
{
name: 'origin-storage-default',
Expand Down Expand Up @@ -40,6 +42,6 @@ const AzionConfig = {
},
],
},
};
});

export default AzionConfig;
export default config;
8 changes: 5 additions & 3 deletions lib/presets/astro/deliver/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

const config = AzionConfig({
origin: [
{
name: 'origin-storage-default',
Expand Down Expand Up @@ -45,6 +47,6 @@ const AzionConfig = {
},
],
},
};
});

export default AzionConfig;
export default config;
8 changes: 5 additions & 3 deletions lib/presets/docusaurus/deliver/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

const config = AzionConfig({
origin: [
{
name: 'origin-storage-default',
Expand Down Expand Up @@ -45,6 +47,6 @@ const AzionConfig = {
},
],
},
};
});

export default AzionConfig;
export default config;
8 changes: 5 additions & 3 deletions lib/presets/eleventy/deliver/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

const config = AzionConfig({
origin: [
{
name: 'origin-storage-default',
Expand Down Expand Up @@ -45,6 +47,6 @@ const AzionConfig = {
},
],
},
};
});

export default AzionConfig;
export default config;
8 changes: 5 additions & 3 deletions lib/presets/emscripten/compute/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

const config = AzionConfig({
rules: {
request: [
{
Expand All @@ -12,6 +14,6 @@ const AzionConfig = {
},
],
},
};
});

export default AzionConfig;
export default config;
8 changes: 4 additions & 4 deletions lib/presets/gatsby/deliver/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

export default AzionConfig({
origin: [
{
name: 'origin-storage-default',
Expand Down Expand Up @@ -45,6 +47,4 @@ const AzionConfig = {
},
],
},
};

export default AzionConfig;
});
8 changes: 4 additions & 4 deletions lib/presets/hexo/deliver/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

export default AzionConfig({
origin: [
{
name: 'origin-storage-default',
Expand Down Expand Up @@ -45,6 +47,4 @@ const AzionConfig = {
},
],
},
};

export default AzionConfig;
});
8 changes: 4 additions & 4 deletions lib/presets/html/deliver/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

export default AzionConfig({
origin: [
{
name: 'origin-storage-default',
Expand All @@ -19,6 +21,4 @@ const AzionConfig = {
},
],
},
};

export default AzionConfig;
});
8 changes: 4 additions & 4 deletions lib/presets/hugo/deliver/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

export default AzionConfig({
origin: [
{
name: 'origin-storage-default',
Expand Down Expand Up @@ -45,6 +47,4 @@ const AzionConfig = {
},
],
},
};

export default AzionConfig;
});
8 changes: 4 additions & 4 deletions lib/presets/javascript/compute/azion.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AzionConfig = {
import { AzionConfig } from 'azion';

export default AzionConfig({
rules: {
request: [
{
Expand All @@ -12,6 +14,4 @@ const AzionConfig = {
},
],
},
};

export default AzionConfig;
});
Loading

0 comments on commit 26fee53

Please sign in to comment.